Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
3abdcf52
Commit
3abdcf52
authored
Jul 27, 2020
by
madengji
Committed by
33cn
Aug 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
para bind miner cmd
parent
073e10e3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
174 additions
and
66 deletions
+174
-66
paracross.go
plugin/dapp/paracross/commands/paracross.go
+83
-0
query.go
plugin/dapp/paracross/executor/query.go
+25
-0
reward.go
plugin/dapp/paracross/executor/reward.go
+57
-63
paracross.proto
plugin/dapp/paracross/proto/paracross.proto
+9
-3
No files found.
plugin/dapp/paracross/commands/paracross.go
View file @
3abdcf52
...
@@ -321,11 +321,13 @@ func superNodeCmd() *cobra.Command {
...
@@ -321,11 +321,13 @@ func superNodeCmd() *cobra.Command {
cmd
.
AddCommand
(
nodeVoteCmd
())
cmd
.
AddCommand
(
nodeVoteCmd
())
cmd
.
AddCommand
(
nodeQuitCmd
())
cmd
.
AddCommand
(
nodeQuitCmd
())
cmd
.
AddCommand
(
nodeCancelCmd
())
cmd
.
AddCommand
(
nodeCancelCmd
())
cmd
.
AddCommand
(
nodeBindCmd
())
cmd
.
AddCommand
(
getNodeInfoCmd
())
cmd
.
AddCommand
(
getNodeInfoCmd
())
cmd
.
AddCommand
(
getNodeIDInfoCmd
())
cmd
.
AddCommand
(
getNodeIDInfoCmd
())
cmd
.
AddCommand
(
getNodeListCmd
())
cmd
.
AddCommand
(
getNodeListCmd
())
cmd
.
AddCommand
(
nodeModifyCmd
())
cmd
.
AddCommand
(
nodeModifyCmd
())
cmd
.
AddCommand
(
getNodeBindListCmd
())
return
cmd
return
cmd
}
}
...
@@ -518,6 +520,87 @@ func createNodeModifyTx(cmd *cobra.Command, args []string) {
...
@@ -518,6 +520,87 @@ func createNodeModifyTx(cmd *cobra.Command, args []string) {
}
}
func
nodeBindCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"bind"
,
Short
:
"bind miner for specific account"
,
Run
:
createNodeBindTx
,
}
addNodeBindFlags
(
cmd
)
return
cmd
}
func
addNodeBindFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
Uint32P
(
"action"
,
"a"
,
1
,
"action bind:1 or unbind:2"
)
cmd
.
MarkFlagRequired
(
"action"
)
cmd
.
Flags
()
.
Uint64P
(
"coins"
,
"c"
,
0
,
"bind coins, unbind not needed"
)
cmd
.
Flags
()
.
StringP
(
"node"
,
"n"
,
""
,
"target node to bind/unbind miner"
)
cmd
.
MarkFlagRequired
(
"node"
)
}
func
createNodeBindTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
paraName
,
_
:=
cmd
.
Flags
()
.
GetString
(
"paraName"
)
action
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"action"
)
node
,
_
:=
cmd
.
Flags
()
.
GetString
(
"node"
)
coins
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"coins"
)
if
!
strings
.
HasPrefix
(
paraName
,
"user.p"
)
{
fmt
.
Fprintln
(
os
.
Stderr
,
"paraName is not right, paraName format like `user.p.guodun.`"
)
return
}
if
action
==
1
&&
coins
==
0
{
fmt
.
Fprintln
(
os
.
Stderr
,
"coins should bigger than 0"
)
}
payload
:=
&
pt
.
ParaBindMinerInfo
{
BindAction
:
int32
(
action
),
BindCount
:
int64
(
coins
),
TargetAddr
:
node
}
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
getRealExecName
(
paraName
,
pt
.
ParaX
),
ActionName
:
"ParaBindMiner"
,
Payload
:
types
.
MustPBToJSON
(
payload
),
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"Chain33.CreateTransaction"
,
params
,
nil
)
ctx
.
RunWithoutMarshal
()
}
func
getNodeBindListCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"bind_list"
,
Short
:
"Get node bind miner account list"
,
Run
:
nodeBindInfo
,
}
addNodeBindCmdFlags
(
cmd
)
return
cmd
}
func
addNodeBindCmdFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"node"
,
"n"
,
""
,
"super node addr to bind miner"
)
cmd
.
MarkFlagRequired
(
"node"
)
}
func
nodeBindInfo
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
addr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr"
)
var
params
rpctypes
.
Query4Jrpc
params
.
Execer
=
pt
.
ParaX
params
.
FuncName
=
"GetNodeBindMinerList"
params
.
Payload
=
types
.
MustPBToJSON
(
&
types
.
ReqString
{
Data
:
addr
})
var
res
pt
.
RespParaNodeBindList
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
.
Run
()
}
// getNodeInfoCmd get node current status
// getNodeInfoCmd get node current status
func
getNodeInfoCmd
()
*
cobra
.
Command
{
func
getNodeInfoCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
...
...
plugin/dapp/paracross/executor/query.go
View file @
3abdcf52
...
@@ -533,3 +533,28 @@ func (p *Paracross) Query_GetHeight(req *types.ReqString) (*pt.ParacrossConsensu
...
@@ -533,3 +533,28 @@ func (p *Paracross) Query_GetHeight(req *types.ReqString) (*pt.ParacrossConsensu
}
}
return
nil
,
types
.
ErrDecode
return
nil
,
types
.
ErrDecode
}
}
// Query_GetNodeBindMinerList query get super node bind miner list
func
(
p
*
Paracross
)
Query_GetNodeBindMinerList
(
in
*
types
.
ReqString
)
(
types
.
Message
,
error
)
{
if
in
==
nil
||
len
(
in
.
Data
)
==
0
{
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"in=%v"
,
in
)
}
list
,
err
:=
getBindNodeInfo
(
p
.
GetStateDB
(),
in
.
Data
)
if
err
!=
nil
{
return
nil
,
err
}
var
resp
pt
.
RespParaNodeBindList
resp
.
List
=
list
for
_
,
addr
:=
range
list
.
Miners
{
info
,
err
:=
getBindAddrInfo
(
p
.
GetStateDB
(),
in
.
Data
,
addr
)
if
err
!=
nil
{
return
nil
,
err
}
resp
.
Details
=
append
(
resp
.
Details
,
info
)
}
return
&
resp
,
nil
}
plugin/dapp/paracross/executor/reward.go
View file @
3abdcf52
This diff is collapsed.
Click to expand it.
plugin/dapp/paracross/proto/paracross.proto
View file @
3abdcf52
...
@@ -161,10 +161,11 @@ message RespParacrossNodeGroups {
...
@@ -161,10 +161,11 @@ message RespParacrossNodeGroups {
//para bind miner
//para bind miner
message
ParaBindMinerInfo
{
message
ParaBindMinerInfo
{
string
addr
=
1
;
// miner addr
string
addr
=
1
;
// miner addr
int32
bind
Status
=
2
;
// 0: init,
1: bind, 2:unbind
int32
bind
Action
=
2
;
//
1: bind, 2:unbind
int64
bindCount
=
3
;
// bind coins count
int64
bindCount
=
3
;
// bind coins count
int64
blockTime
=
4
;
// status bind block time
string
targetAddr
=
4
;
// super node addr
string
targetAddr
=
5
;
// super node addr
int64
blockTime
=
5
;
// action bind block time
int64
blockHeight
=
6
;
// action bind block height
}
}
message
ReceiptParaBindMinerInfo
{
message
ReceiptParaBindMinerInfo
{
...
@@ -183,6 +184,11 @@ message ReceiptParaNodeBindListUpdate{
...
@@ -183,6 +184,11 @@ message ReceiptParaNodeBindListUpdate{
ParaNodeBindList
current
=
2
;
ParaNodeBindList
current
=
2
;
}
}
message
RespParaNodeBindList
{
ParaNodeBindList
list
=
1
;
repeated
ParaBindMinerInfo
details
=
2
;
}
message
ParaBlock2MainMap
{
message
ParaBlock2MainMap
{
int64
height
=
1
;
int64
height
=
1
;
string
blockHash
=
2
;
string
blockHash
=
2
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment