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
09f609fb
Commit
09f609fb
authored
Jun 02, 2019
by
mdj33
Committed by
vipwzw
Jun 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify nodegroup and node
parent
dd78db9e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
84 additions
and
67 deletions
+84
-67
paracross.go
plugin/dapp/paracross/commands/paracross.go
+15
-19
action.go
plugin/dapp/paracross/executor/action.go
+6
-1
exec_del_local.go
plugin/dapp/paracross/executor/exec_del_local.go
+5
-6
exec_local.go
plugin/dapp/paracross/executor/exec_local.go
+5
-6
kv.go
plugin/dapp/paracross/executor/kv.go
+14
-6
query.go
plugin/dapp/paracross/executor/query.go
+6
-2
superaccount.go
plugin/dapp/paracross/executor/superaccount.go
+0
-0
superaccount_test.go
plugin/dapp/paracross/executor/superaccount_test.go
+2
-2
paracross.proto
plugin/dapp/paracross/proto/paracross.proto
+14
-10
rpc.go
plugin/dapp/paracross/rpc/rpc.go
+2
-2
paracross.go
plugin/dapp/paracross/types/paracross.go
+14
-9
type.go
plugin/dapp/paracross/types/type.go
+1
-4
No files found.
plugin/dapp/paracross/commands/paracross.go
View file @
09f609fb
...
@@ -251,36 +251,30 @@ func CreateRawNodeManageCmd() *cobra.Command {
...
@@ -251,36 +251,30 @@ func CreateRawNodeManageCmd() *cobra.Command {
}
}
func
addNodeManageFlags
(
cmd
*
cobra
.
Command
)
{
func
addNodeManageFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"operation"
,
"o"
,
""
,
"operation:join,quit,vote
"
)
cmd
.
Flags
()
.
Uint32P
(
"operation"
,
"o"
,
0
,
"operation:1:join,2:vote,3:quit
"
)
cmd
.
MarkFlagRequired
(
"operation"
)
cmd
.
MarkFlagRequired
(
"operation"
)
cmd
.
Flags
()
.
StringP
(
"addr"
,
"a"
,
""
,
"operating target addr"
)
cmd
.
Flags
()
.
StringP
(
"addr"
,
"a"
,
""
,
"operating target addr"
)
cmd
.
MarkFlagRequired
(
"addrs"
)
cmd
.
Flags
()
.
StringP
(
"value"
,
"v"
,
""
,
"vote value: yes,no"
)
cmd
.
Flags
()
.
StringP
(
"id"
,
"i"
,
""
,
"operating target id"
)
cmd
.
Flags
()
.
Float64P
(
"coins_frozen"
,
"c"
,
0
,
"join to frozen coins amount, not less config"
)
cmd
.
Flags
()
.
Uint32P
(
"value"
,
"v"
,
1
,
"vote value: 1:yes,2:no"
)
cmd
.
Flags
()
.
Float64P
(
"coins_frozen"
,
"c"
,
0
,
"frozen coins amount, should not less nodegroup's"
)
}
}
func
createNodeTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
createNodeTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
op
,
_
:=
cmd
.
Flags
()
.
Get
String
(
"operation"
)
op
,
_
:=
cmd
.
Flags
()
.
Get
Uint32
(
"operation"
)
opAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr"
)
opAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr"
)
val
,
_
:=
cmd
.
Flags
()
.
GetString
(
"value"
)
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
val
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"value"
)
coins
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"coins_frozen"
)
coins
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"coins_frozen"
)
if
op
!=
"vote"
&&
op
!=
"quit"
&&
op
!=
"join"
{
fmt
.
Println
(
"operation should be one of join,quit,vote"
)
return
}
if
opAddr
==
""
{
if
opAddr
==
""
{
fmt
.
Println
(
"addr parameter should not be null"
)
fmt
.
Println
(
"addr parameter should not be null"
)
return
return
}
}
if
op
==
"vote"
&&
(
val
!=
"yes"
&&
val
!=
"no"
)
{
fmt
.
Println
(
"vote operation value parameter require yes or no value"
)
return
}
payload
:=
&
pt
.
ParaNodeAddrConfig
{
Op
:
op
,
Value
:
val
,
Addr
:
opAddr
,
CoinsFrozen
:
int64
(
math
.
Trunc
((
coins
+
0.0000001
)
*
1e4
))
*
1e4
}
payload
:=
&
pt
.
ParaNodeAddrConfig
{
Op
:
op
,
Id
:
id
,
Value
:
val
,
Addr
:
opAddr
,
CoinsFrozen
:
int64
(
math
.
Trunc
((
coins
+
0.0000001
)
*
1e4
))
*
1e4
}
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pt
.
ParaX
),
Execer
:
types
.
ExecName
(
pt
.
ParaX
),
ActionName
:
"NodeConfig"
,
ActionName
:
"NodeConfig"
,
...
@@ -305,11 +299,12 @@ func CreateNodeGroupApplyCmd() *cobra.Command {
...
@@ -305,11 +299,12 @@ func CreateNodeGroupApplyCmd() *cobra.Command {
}
}
func
addNodeGroupApplyCmdFlags
(
cmd
*
cobra
.
Command
)
{
func
addNodeGroupApplyCmdFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
Uint32P
(
"operation"
,
"o"
,
0
,
"operation:1:apply,2:approve,3:quit"
)
cmd
.
Flags
()
.
Uint32P
(
"operation"
,
"o"
,
0
,
"operation:1:apply,2:approve,3:quit
,4:modify
"
)
cmd
.
MarkFlagRequired
(
"operation"
)
cmd
.
MarkFlagRequired
(
"operation"
)
cmd
.
Flags
()
.
StringP
(
"id"
,
"i"
,
""
,
"apply id for nodegroup "
)
cmd
.
Flags
()
.
StringP
(
"addrs"
,
"a"
,
""
,
"addrs apply for super node,split by ',' "
)
cmd
.
Flags
()
.
StringP
(
"addrs"
,
"a"
,
""
,
"addrs apply for super node,split by ',' "
)
cmd
.
MarkFlagRequired
(
"addrs"
)
cmd
.
Flags
()
.
Float64P
(
"coins_frozen"
,
"c"
,
0
,
"coins amount to frozen, not less config"
)
cmd
.
Flags
()
.
Float64P
(
"coins_frozen"
,
"c"
,
0
,
"coins amount to frozen, not less config"
)
...
@@ -318,6 +313,7 @@ func addNodeGroupApplyCmdFlags(cmd *cobra.Command) {
...
@@ -318,6 +313,7 @@ func addNodeGroupApplyCmdFlags(cmd *cobra.Command) {
func
nodeGroupApply
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
nodeGroupApply
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
op
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"operation"
)
op
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"operation"
)
addrs
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addrs"
)
addrs
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addrs"
)
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
coins
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"coins_frozen"
)
coins
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"coins_frozen"
)
if
op
==
0
||
op
>
3
{
if
op
==
0
||
op
>
3
{
...
@@ -329,7 +325,7 @@ func nodeGroupApply(cmd *cobra.Command, args []string) {
...
@@ -329,7 +325,7 @@ func nodeGroupApply(cmd *cobra.Command, args []string) {
return
return
}
}
payload
:=
&
pt
.
ParaNodeGroupConfig
{
Op
:
op
,
Addrs
:
addrs
,
CoinsFrozen
:
int64
(
math
.
Trunc
((
coins
+
0.0000001
)
*
1e4
))
*
1e4
}
payload
:=
&
pt
.
ParaNodeGroupConfig
{
Op
:
op
,
Id
:
id
,
Addrs
:
addrs
,
CoinsFrozen
:
int64
(
math
.
Trunc
((
coins
+
0.0000001
)
*
1e4
))
*
1e4
}
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pt
.
ParaX
),
Execer
:
types
.
ExecName
(
pt
.
ParaX
),
ActionName
:
"NodeGroupConfig"
,
ActionName
:
"NodeGroupConfig"
,
...
@@ -499,7 +495,7 @@ func nodeInfo(cmd *cobra.Command, args []string) {
...
@@ -499,7 +495,7 @@ func nodeInfo(cmd *cobra.Command, args []string) {
Title
:
title
,
Title
:
title
,
Addr
:
addr
,
Addr
:
addr
,
}
}
var
res
pt
.
ParaNode
Addr
Status
var
res
pt
.
ParaNode
Id
Status
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"paracross.GetNodeStatus"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"paracross.GetNodeStatus"
,
params
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
...
plugin/dapp/paracross/executor/action.go
View file @
09f609fb
...
@@ -418,7 +418,12 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
...
@@ -418,7 +418,12 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
return
receipt
,
nil
return
receipt
,
nil
}
}
if
enableParacrossTransfer
&&
commit
.
Status
.
Height
>
0
&&
len
(
commit
.
Status
.
CrossTxHashs
)
>
0
{
haveCrossTxs
:=
len
(
commit
.
Status
.
CrossTxHashs
)
>
0
if
types
.
IsDappFork
(
a
.
height
,
pt
.
ParaX
,
pt
.
ForkCommitTx
)
&&
commit
.
Status
.
CrossTxHashs
[
0
]
==
nil
{
haveCrossTxs
=
false
}
if
enableParacrossTransfer
&&
commit
.
Status
.
Height
>
0
&&
haveCrossTxs
{
clog
.
Debug
(
"paracross.Commit commitDone"
,
"do cross"
,
""
)
clog
.
Debug
(
"paracross.Commit commitDone"
,
"do cross"
,
""
)
crossTxReceipt
,
err
:=
a
.
execCrossTxs
(
commit
)
crossTxReceipt
,
err
:=
a
.
execCrossTxs
(
commit
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
plugin/dapp/paracross/executor/exec_del_local.go
View file @
09f609fb
...
@@ -64,11 +64,11 @@ func (e *Paracross) ExecDelLocal_NodeConfig(payload *pt.ParaNodeAddrConfig, tx *
...
@@ -64,11 +64,11 @@ func (e *Paracross) ExecDelLocal_NodeConfig(payload *pt.ParaNodeAddrConfig, tx *
}
}
if
g
.
Prev
!=
nil
{
if
g
.
Prev
!=
nil
{
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
Key
:
calcLocalNodeTitleStatus
(
g
.
Current
.
Title
,
g
.
Current
.
ApplyAddr
,
g
.
Prev
.
Status
),
Value
:
types
.
Encode
(
g
.
Prev
)})
Key
:
calcLocalNodeTitleStatus
(
g
.
Current
.
Title
,
g
.
Prev
.
Status
,
g
.
Prev
.
Id
),
Value
:
types
.
Encode
(
g
.
Prev
)})
}
}
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
Key
:
calcLocalNodeTitleStatus
(
g
.
Current
.
Title
,
g
.
Current
.
ApplyAddr
,
g
.
Current
.
Status
),
Value
:
nil
})
Key
:
calcLocalNodeTitleStatus
(
g
.
Current
.
Title
,
g
.
Current
.
Status
,
g
.
Current
.
Id
),
Value
:
nil
})
}
else
if
log
.
Ty
==
pt
.
TyLogParaNodeVoteDone
{
}
else
if
log
.
Ty
==
pt
.
TyLogParaNodeVoteDone
{
var
g
pt
.
ReceiptParaNodeVoteDone
var
g
pt
.
ReceiptParaNodeVoteDone
err
:=
types
.
Decode
(
log
.
Log
,
&
g
)
err
:=
types
.
Decode
(
log
.
Log
,
&
g
)
...
@@ -86,8 +86,7 @@ func (e *Paracross) ExecDelLocal_NodeConfig(payload *pt.ParaNodeAddrConfig, tx *
...
@@ -86,8 +86,7 @@ func (e *Paracross) ExecDelLocal_NodeConfig(payload *pt.ParaNodeAddrConfig, tx *
func
(
e
*
Paracross
)
ExecDelLocal_NodeGroupConfig
(
payload
*
pt
.
ParaNodeGroupConfig
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
e
*
Paracross
)
ExecDelLocal_NodeGroupConfig
(
payload
*
pt
.
ParaNodeGroupConfig
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
var
set
types
.
LocalDBSet
var
set
types
.
LocalDBSet
for
_
,
log
:=
range
receiptData
.
Logs
{
for
_
,
log
:=
range
receiptData
.
Logs
{
if
log
.
Ty
==
pt
.
TyLogParaNodeGroupApply
||
log
.
Ty
==
pt
.
TyLogParaNodeGroupApprove
||
if
log
.
Ty
==
pt
.
TyLogParaNodeGroupConfig
{
log
.
Ty
==
pt
.
TyLogParaNodeGroupQuit
{
var
g
pt
.
ReceiptParaNodeGroupConfig
var
g
pt
.
ReceiptParaNodeGroupConfig
err
:=
types
.
Decode
(
log
.
Log
,
&
g
)
err
:=
types
.
Decode
(
log
.
Log
,
&
g
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -95,11 +94,11 @@ func (e *Paracross) ExecDelLocal_NodeGroupConfig(payload *pt.ParaNodeGroupConfig
...
@@ -95,11 +94,11 @@ func (e *Paracross) ExecDelLocal_NodeGroupConfig(payload *pt.ParaNodeGroupConfig
}
}
if
g
.
Prev
!=
nil
{
if
g
.
Prev
!=
nil
{
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
Key
:
calcLocalNodeGroupStatusTitle
(
g
.
Prev
.
Status
,
g
.
Current
.
Title
),
Value
:
types
.
Encode
(
g
.
Prev
)})
Key
:
calcLocalNodeGroupStatusTitle
(
g
.
Prev
.
Status
,
g
.
Current
.
Title
,
g
.
Current
.
Id
),
Value
:
types
.
Encode
(
g
.
Prev
)})
}
}
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
Key
:
calcLocalNodeGroupStatusTitle
(
g
.
Current
.
Status
,
g
.
Current
.
Title
),
Value
:
nil
})
Key
:
calcLocalNodeGroupStatusTitle
(
g
.
Current
.
Status
,
g
.
Current
.
Title
,
g
.
Current
.
Id
),
Value
:
nil
})
}
}
}
}
return
&
set
,
nil
return
&
set
,
nil
...
...
plugin/dapp/paracross/executor/exec_local.go
View file @
09f609fb
...
@@ -67,11 +67,11 @@ func (e *Paracross) ExecLocal_NodeConfig(payload *pt.ParaNodeAddrConfig, tx *typ
...
@@ -67,11 +67,11 @@ func (e *Paracross) ExecLocal_NodeConfig(payload *pt.ParaNodeAddrConfig, tx *typ
}
}
if
g
.
Prev
!=
nil
{
if
g
.
Prev
!=
nil
{
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
Key
:
calcLocalNodeTitleStatus
(
g
.
Current
.
Title
,
g
.
Current
.
ApplyAddr
,
g
.
Prev
.
Status
),
Value
:
nil
})
Key
:
calcLocalNodeTitleStatus
(
g
.
Current
.
Title
,
g
.
Prev
.
Status
,
g
.
Current
.
Id
),
Value
:
nil
})
}
}
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
Key
:
calcLocalNodeTitleStatus
(
g
.
Current
.
Title
,
g
.
Current
.
ApplyAddr
,
g
.
Current
.
Status
),
Key
:
calcLocalNodeTitleStatus
(
g
.
Current
.
Title
,
g
.
Current
.
Status
,
g
.
Current
.
Id
),
Value
:
types
.
Encode
(
g
.
Current
)})
Value
:
types
.
Encode
(
g
.
Current
)})
}
else
if
log
.
Ty
==
pt
.
TyLogParaNodeVoteDone
{
}
else
if
log
.
Ty
==
pt
.
TyLogParaNodeVoteDone
{
var
g
pt
.
ReceiptParaNodeVoteDone
var
g
pt
.
ReceiptParaNodeVoteDone
...
@@ -90,8 +90,7 @@ func (e *Paracross) ExecLocal_NodeConfig(payload *pt.ParaNodeAddrConfig, tx *typ
...
@@ -90,8 +90,7 @@ func (e *Paracross) ExecLocal_NodeConfig(payload *pt.ParaNodeAddrConfig, tx *typ
func
(
e
*
Paracross
)
ExecLocal_NodeGroupConfig
(
payload
*
pt
.
ParaNodeGroupConfig
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
e
*
Paracross
)
ExecLocal_NodeGroupConfig
(
payload
*
pt
.
ParaNodeGroupConfig
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
var
set
types
.
LocalDBSet
var
set
types
.
LocalDBSet
for
_
,
log
:=
range
receiptData
.
Logs
{
for
_
,
log
:=
range
receiptData
.
Logs
{
if
log
.
Ty
==
pt
.
TyLogParaNodeGroupApply
||
log
.
Ty
==
pt
.
TyLogParaNodeGroupApprove
||
if
log
.
Ty
==
pt
.
TyLogParaNodeGroupConfig
{
log
.
Ty
==
pt
.
TyLogParaNodeGroupQuit
||
log
.
Ty
==
pt
.
TyLogParaNodeGroupModify
{
var
g
pt
.
ReceiptParaNodeGroupConfig
var
g
pt
.
ReceiptParaNodeGroupConfig
err
:=
types
.
Decode
(
log
.
Log
,
&
g
)
err
:=
types
.
Decode
(
log
.
Log
,
&
g
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -99,11 +98,11 @@ func (e *Paracross) ExecLocal_NodeGroupConfig(payload *pt.ParaNodeGroupConfig, t
...
@@ -99,11 +98,11 @@ func (e *Paracross) ExecLocal_NodeGroupConfig(payload *pt.ParaNodeGroupConfig, t
}
}
if
g
.
Prev
!=
nil
{
if
g
.
Prev
!=
nil
{
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
Key
:
calcLocalNodeGroupStatusTitle
(
g
.
Prev
.
Status
,
g
.
Current
.
Title
),
Value
:
nil
})
Key
:
calcLocalNodeGroupStatusTitle
(
g
.
Prev
.
Status
,
g
.
Current
.
Title
,
g
.
Current
.
Id
),
Value
:
nil
})
}
}
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
Key
:
calcLocalNodeGroupStatusTitle
(
g
.
Current
.
Status
,
g
.
Current
.
Title
),
Value
:
types
.
Encode
(
g
.
Current
)})
Key
:
calcLocalNodeGroupStatusTitle
(
g
.
Current
.
Status
,
g
.
Current
.
Title
,
g
.
Current
.
Id
),
Value
:
types
.
Encode
(
g
.
Current
)})
}
}
}
}
return
&
set
,
nil
return
&
set
,
nil
...
...
plugin/dapp/paracross/executor/kv.go
View file @
09f609fb
...
@@ -102,22 +102,30 @@ func calcLocalAssetKey(hash []byte) []byte {
...
@@ -102,22 +102,30 @@ func calcLocalAssetKey(hash []byte) []byte {
return
[]
byte
(
fmt
.
Sprintf
(
localAssetKey
+
"%s"
,
hash
))
return
[]
byte
(
fmt
.
Sprintf
(
localAssetKey
+
"%s"
,
hash
))
}
}
func
calcLocalNodeTitleStatus
(
title
,
addr
string
,
status
int32
)
[]
byte
{
func
calcLocalNodeTitleStatus
(
title
string
,
status
int32
,
id
string
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
localNodeTitleStatus
+
"%s-%02d-%s"
,
title
,
status
,
addr
))
return
[]
byte
(
fmt
.
Sprintf
(
localNodeTitleStatus
+
"%s-%02d-%s"
,
title
,
status
,
id
))
}
}
func
calcLocalNodeStatusPrefix
(
title
string
,
status
int32
)
[]
byte
{
func
calcLocalNodeStatusPrefix
(
title
string
,
status
int32
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
localNodeTitleStatus
+
"%s-%02d"
,
title
,
status
))
return
[]
byte
(
fmt
.
Sprintf
(
localNodeTitleStatus
+
"%s-%02d-"
,
title
,
status
))
}
func
calcLocalNodeTitlePrefix
(
title
string
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
localNodeTitleStatus
+
"%s-"
,
title
))
}
}
func
calcLocalNodeTitleDone
(
title
,
addr
string
)
[]
byte
{
func
calcLocalNodeTitleDone
(
title
,
addr
string
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
localNodeTitleDone
+
"%s-%s"
,
title
,
addr
))
return
[]
byte
(
fmt
.
Sprintf
(
localNodeTitleDone
+
"%s-%s"
,
title
,
addr
))
}
}
func
calcLocalNodeGroupStatusTitle
(
status
int32
,
title
string
)
[]
byte
{
func
calcLocalNodeGroupStatusTitle
(
status
int32
,
title
,
id
string
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
localNodeGroupStatusTitle
+
"%02d-%s
"
,
status
,
title
))
return
[]
byte
(
fmt
.
Sprintf
(
localNodeGroupStatusTitle
+
"%02d-%s
-%s"
,
status
,
title
,
id
))
}
}
func
calcLocalNodeGroupStatusPrefix
(
status
int32
)
[]
byte
{
func
calcLocalNodeGroupStatusPrefix
(
status
int32
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
localNodeGroupStatusTitle
+
"%02d"
,
status
))
return
[]
byte
(
fmt
.
Sprintf
(
localNodeGroupStatusTitle
+
"%02d-"
,
status
))
}
func
calcLocalNodeGroupAllPrefix
()
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
localNodeGroupStatusTitle
))
}
}
plugin/dapp/paracross/executor/query.go
View file @
09f609fb
...
@@ -85,7 +85,11 @@ func (p *Paracross) Query_GetNodeAddrInfo(in *pt.ReqParacrossNodeInfo) (types.Me
...
@@ -85,7 +85,11 @@ func (p *Paracross) Query_GetNodeAddrInfo(in *pt.ReqParacrossNodeInfo) (types.Me
if
in
==
nil
||
in
.
Title
==
""
||
in
.
Addr
==
""
{
if
in
==
nil
||
in
.
Title
==
""
||
in
.
Addr
==
""
{
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
stat
,
err
:=
getNodeAddr
(
p
.
GetStateDB
(),
in
.
Title
,
in
.
Addr
)
addrStat
,
err
:=
getNodeAddr
(
p
.
GetStateDB
(),
in
.
Title
,
in
.
Addr
)
if
err
!=
nil
{
return
nil
,
err
}
stat
,
err
:=
getNodeId
(
p
.
GetStateDB
(),
addrStat
.
ProposalId
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -230,7 +234,7 @@ func listNodeStatus(db dbm.KVDB, prefix []byte) (types.Message, error) {
...
@@ -230,7 +234,7 @@ func listNodeStatus(db dbm.KVDB, prefix []byte) (types.Message, error) {
var
resp
pt
.
RespParacrossNodeAddrs
var
resp
pt
.
RespParacrossNodeAddrs
for
_
,
r
:=
range
res
{
for
_
,
r
:=
range
res
{
var
st
pt
.
ParaNode
Addr
Status
var
st
pt
.
ParaNode
Id
Status
err
=
types
.
Decode
(
r
,
&
st
)
err
=
types
.
Decode
(
r
,
&
st
)
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
err
)
panic
(
err
)
...
...
plugin/dapp/paracross/executor/superaccount.go
View file @
09f609fb
This diff is collapsed.
Click to expand it.
plugin/dapp/paracross/executor/superaccount_test.go
View file @
09f609fb
...
@@ -108,7 +108,7 @@ func checkGroupApplyReceipt(suite *NodeManageTestSuite, receipt *types.Receipt)
...
@@ -108,7 +108,7 @@ func checkGroupApplyReceipt(suite *NodeManageTestSuite, receipt *types.Receipt)
err
:=
types
.
Decode
(
receipt
.
KV
[
0
]
.
Value
,
&
stat
)
err
:=
types
.
Decode
(
receipt
.
KV
[
0
]
.
Value
,
&
stat
)
assert
.
Nil
(
suite
.
T
(),
err
,
"decode ParaNodeAddrStatus failed"
)
assert
.
Nil
(
suite
.
T
(),
err
,
"decode ParaNodeAddrStatus failed"
)
//suite.T().Log("titleHeight", titleHeight)
//suite.T().Log("titleHeight", titleHeight)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
TyLogParaNodeGroup
Apply
),
receipt
.
Logs
[
0
]
.
Ty
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
TyLogParaNodeGroup
Config
),
receipt
.
Logs
[
0
]
.
Ty
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
ParacrossNodeGroupApply
),
stat
.
Status
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
ParacrossNodeGroupApply
),
stat
.
Status
)
}
}
...
@@ -124,7 +124,7 @@ func checkGroupApproveReceipt(suite *NodeManageTestSuite, receipt *types.Receipt
...
@@ -124,7 +124,7 @@ func checkGroupApproveReceipt(suite *NodeManageTestSuite, receipt *types.Receipt
err
:=
types
.
Decode
(
receipt
.
KV
[
len
-
1
]
.
Value
,
&
stat
)
err
:=
types
.
Decode
(
receipt
.
KV
[
len
-
1
]
.
Value
,
&
stat
)
assert
.
Nil
(
suite
.
T
(),
err
,
"decode ParaNodeAddrStatus failed"
)
assert
.
Nil
(
suite
.
T
(),
err
,
"decode ParaNodeAddrStatus failed"
)
//suite.T().Log("titleHeight", titleHeight)
//suite.T().Log("titleHeight", titleHeight)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
TyLogParaNodeGroup
Approve
),
receipt
.
Logs
[
len
-
1
]
.
Ty
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
TyLogParaNodeGroup
Config
),
receipt
.
Logs
[
len
-
1
]
.
Ty
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
ParacrossNodeGroupApprove
),
stat
.
Status
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
ParacrossNodeGroupApprove
),
stat
.
Status
)
}
}
...
...
plugin/dapp/paracross/proto/paracross.proto
View file @
09f609fb
...
@@ -47,26 +47,30 @@ message ParacrossConsensusStatus {
...
@@ -47,26 +47,30 @@ message ParacrossConsensusStatus {
string
consensBlockHash
=
4
;
string
consensBlockHash
=
4
;
}
}
message
ParaNodeAddrConfig
{
message
ParaNodeAddrConfig
{
string
title
=
1
;
string
title
=
1
;
string
op
=
2
;
uint32
op
=
2
;
string
id
=
3
;
string
id
=
3
;
string
addr
=
4
;
string
addr
=
4
;
string
value
=
5
;
uint32
value
=
5
;
int64
coinsFrozen
=
6
;
int64
coinsFrozen
=
6
;
}
}
message
ParaNodeVoteDetail
{
message
ParaNodeVoteDetail
{
repeated
string
addrs
=
1
;
repeated
string
addrs
=
1
;
repeated
string
votes
=
2
;
repeated
string
votes
=
2
;
}
}
message
ParaNodeAddrStatus
{
message
ParaNodeAddrIdStatus
{
string
proposalId
=
1
;
}
message
ParaNodeIdStatus
{
string
id
=
1
;
string
id
=
1
;
int32
status
=
2
;
int32
status
=
2
;
string
title
=
3
;
string
title
=
3
;
string
applyAddr
=
4
;
string
targetAddr
=
4
;
int64
coinsFrozen
=
5
;
int64
coinsFrozen
=
5
;
ParaNodeVoteDetail
votes
=
6
;
ParaNodeVoteDetail
votes
=
6
;
string
fromAddr
=
7
;
string
fromAddr
=
7
;
...
@@ -76,8 +80,8 @@ message ParaNodeAddrStatus{
...
@@ -76,8 +80,8 @@ message ParaNodeAddrStatus{
message
ReceiptParaNodeConfig
{
message
ReceiptParaNodeConfig
{
string
addr
=
1
;
string
addr
=
1
;
ParaNodeAddrConfig
config
=
2
;
ParaNodeAddrConfig
config
=
2
;
ParaNode
AddrStatus
prev
=
3
;
ParaNode
IdStatus
prev
=
3
;
ParaNode
AddrStatus
current
=
4
;
ParaNode
IdStatus
current
=
4
;
}
}
...
@@ -107,7 +111,7 @@ message ParaNodeGroupStatus {
...
@@ -107,7 +111,7 @@ message ParaNodeGroupStatus {
string
id
=
1
;
string
id
=
1
;
int32
status
=
2
;
int32
status
=
2
;
string
title
=
3
;
string
title
=
3
;
string
applyAddrs
=
4
;
string
targetAddrs
=
4
;
int64
coinsFrozen
=
5
;
int64
coinsFrozen
=
5
;
uint32
emptyBlockInterval
=
6
;
uint32
emptyBlockInterval
=
6
;
int64
mainHeight
=
7
;
int64
mainHeight
=
7
;
...
@@ -130,7 +134,7 @@ message ReqParacrossNodeInfo {
...
@@ -130,7 +134,7 @@ message ReqParacrossNodeInfo {
}
}
message
RespParacrossNodeAddrs
{
message
RespParacrossNodeAddrs
{
repeated
ParaNode
Addr
Status
addrs
=
1
;
repeated
ParaNode
Id
Status
addrs
=
1
;
}
}
message
RespParacrossNodeGroups
{
message
RespParacrossNodeGroups
{
...
...
plugin/dapp/paracross/rpc/rpc.go
View file @
09f609fb
...
@@ -180,13 +180,13 @@ func (c *Jrpc) GetBlock2MainInfo(req *types.ReqBlocks, result *interface{}) erro
...
@@ -180,13 +180,13 @@ func (c *Jrpc) GetBlock2MainInfo(req *types.ReqBlocks, result *interface{}) erro
}
}
// GetNodeStatus get super node status
// GetNodeStatus get super node status
func
(
c
*
channelClient
)
GetNodeStatus
(
ctx
context
.
Context
,
req
*
pt
.
ReqParacrossNodeInfo
)
(
*
pt
.
ParaNode
Addr
Status
,
error
)
{
func
(
c
*
channelClient
)
GetNodeStatus
(
ctx
context
.
Context
,
req
*
pt
.
ReqParacrossNodeInfo
)
(
*
pt
.
ParaNode
Id
Status
,
error
)
{
r
:=
*
req
r
:=
*
req
data
,
err
:=
c
.
Query
(
pt
.
GetExecName
(),
"GetNodeAddrInfo"
,
&
r
)
data
,
err
:=
c
.
Query
(
pt
.
GetExecName
(),
"GetNodeAddrInfo"
,
&
r
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
resp
,
ok
:=
data
.
(
*
pt
.
ParaNode
Addr
Status
);
ok
{
if
resp
,
ok
:=
data
.
(
*
pt
.
ParaNode
Id
Status
);
ok
{
return
resp
,
nil
return
resp
,
nil
}
}
return
nil
,
types
.
ErrDecode
return
nil
,
types
.
ErrDecode
...
...
plugin/dapp/paracross/types/paracross.go
View file @
09f609fb
...
@@ -40,10 +40,7 @@ const (
...
@@ -40,10 +40,7 @@ const (
TyLogParaNodeConfig
=
657
TyLogParaNodeConfig
=
657
TyLogParaNodeVoteDone
=
658
TyLogParaNodeVoteDone
=
658
TyLogParaNodeGroupAddrsUpdate
=
659
TyLogParaNodeGroupAddrsUpdate
=
659
TyLogParaNodeGroupApply
=
660
TyLogParaNodeGroupConfig
=
660
TyLogParaNodeGroupApprove
=
661
TyLogParaNodeGroupQuit
=
662
TyLogParaNodeGroupModify
=
663
TyLogParaNodeGroupStatusUpdate
=
664
TyLogParaNodeGroupStatusUpdate
=
664
)
)
...
@@ -92,14 +89,20 @@ const (
...
@@ -92,14 +89,20 @@ const (
// node config op
// node config op
const
(
const
(
ParaNodeJoin
=
"join"
ParaNodeJoin
=
iota
+
1
ParaNodeQuit
=
"quit"
ParaNodeVote
ParaNodeVote
=
"vote"
ParaNodeQuit
)
ParaNodeVoteYes
=
"yes"
const
(
ParaNodeVoteNo
=
"no"
ParaNodeVoteInvalid
=
iota
ParaNodeVoteYes
ParaNodeVoteNo
ParaNodeVoteEnd
)
)
var
ParaNodeVoteStr
=
[]
string
{
"invalid"
,
"yes"
,
"no"
}
const
(
const
(
// ParacrossNodeJoining apply for adding group
// ParacrossNodeJoining apply for adding group
ParacrossNodeJoining
=
iota
+
1
ParacrossNodeJoining
=
iota
+
1
...
@@ -183,6 +186,7 @@ func createRawCommitTx(status *ParacrossNodeStatus, name string, fee int64) (*ty
...
@@ -183,6 +186,7 @@ func createRawCommitTx(status *ParacrossNodeStatus, name string, fee int64) (*ty
func
CreateRawNodeConfigTx
(
config
*
ParaNodeAddrConfig
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawNodeConfigTx
(
config
*
ParaNodeAddrConfig
)
(
*
types
.
Transaction
,
error
)
{
config
.
Title
=
types
.
GetTitle
()
config
.
Title
=
types
.
GetTitle
()
config
.
Addr
=
strings
.
Trim
(
config
.
Addr
,
" "
)
config
.
Addr
=
strings
.
Trim
(
config
.
Addr
,
" "
)
config
.
Id
=
strings
.
Trim
(
config
.
Id
,
" "
)
action
:=
&
ParacrossAction
{
action
:=
&
ParacrossAction
{
Ty
:
ParacrossActionNodeConfig
,
Ty
:
ParacrossActionNodeConfig
,
...
@@ -199,6 +203,7 @@ func CreateRawNodeConfigTx(config *ParaNodeAddrConfig) (*types.Transaction, erro
...
@@ -199,6 +203,7 @@ func CreateRawNodeConfigTx(config *ParaNodeAddrConfig) (*types.Transaction, erro
func
CreateRawNodeGroupApplyTx
(
apply
*
ParaNodeGroupConfig
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawNodeGroupApplyTx
(
apply
*
ParaNodeGroupConfig
)
(
*
types
.
Transaction
,
error
)
{
apply
.
Title
=
types
.
GetTitle
()
apply
.
Title
=
types
.
GetTitle
()
apply
.
EmptyBlockInterval
=
4
apply
.
EmptyBlockInterval
=
4
apply
.
Id
=
strings
.
Trim
(
apply
.
Id
,
" "
)
interval
:=
types
.
Conf
(
"config.consensus.sub.para"
)
.
GInt
(
"emptyBlockInterval"
)
interval
:=
types
.
Conf
(
"config.consensus.sub.para"
)
.
GInt
(
"emptyBlockInterval"
)
if
interval
>
0
{
if
interval
>
0
{
apply
.
EmptyBlockInterval
=
uint32
(
interval
)
apply
.
EmptyBlockInterval
=
uint32
(
interval
)
...
...
plugin/dapp/paracross/types/type.go
View file @
09f609fb
...
@@ -64,10 +64,7 @@ func (p *ParacrossType) GetLogMap() map[int64]*types.LogInfo {
...
@@ -64,10 +64,7 @@ func (p *ParacrossType) GetLogMap() map[int64]*types.LogInfo {
TyLogParaNodeConfig
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeConfig
{}),
Name
:
"LogParaNodeConfig"
},
TyLogParaNodeConfig
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeConfig
{}),
Name
:
"LogParaNodeConfig"
},
TyLogParaNodeGroupAddrsUpdate
:
{
Ty
:
reflect
.
TypeOf
(
types
.
ReceiptConfig
{}),
Name
:
"LogParaNodeGroupAddrsUpdate"
},
TyLogParaNodeGroupAddrsUpdate
:
{
Ty
:
reflect
.
TypeOf
(
types
.
ReceiptConfig
{}),
Name
:
"LogParaNodeGroupAddrsUpdate"
},
TyLogParaNodeVoteDone
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeVoteDone
{}),
Name
:
"LogParaNodeVoteDone"
},
TyLogParaNodeVoteDone
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeVoteDone
{}),
Name
:
"LogParaNodeVoteDone"
},
TyLogParaNodeGroupApply
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeGroupConfig
{}),
Name
:
"LogParaNodeGroupApply"
},
TyLogParaNodeGroupConfig
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeGroupConfig
{}),
Name
:
"LogParaNodeGroupApply"
},
TyLogParaNodeGroupApprove
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeGroupConfig
{}),
Name
:
"LogParaNodeGroupApprove"
},
TyLogParaNodeGroupQuit
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeGroupConfig
{}),
Name
:
"LogParaNodeGroupQuit"
},
TyLogParaNodeGroupModify
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeGroupConfig
{}),
Name
:
"LogParaNodeGroupModify"
},
TyLogParaNodeGroupStatusUpdate
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeGroupConfig
{}),
Name
:
"LogParaNodeGroupStatusUpdate"
},
TyLogParaNodeGroupStatusUpdate
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeGroupConfig
{}),
Name
:
"LogParaNodeGroupStatusUpdate"
},
}
}
}
}
...
...
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