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
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
145 additions
and
141 deletions
+145
-141
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
+61
-74
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 {
}
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
.
Flags
()
.
StringP
(
"addr"
,
"a"
,
""
,
"operating target addr"
)
cmd
.
MarkFlagRequired
(
"addrs"
)
cmd
.
Flags
()
.
StringP
(
"value"
,
"v"
,
""
,
"vote value: yes,no"
)
cmd
.
Flags
()
.
Float64P
(
"coins_frozen"
,
"c"
,
0
,
"join to frozen coins amount, not less config"
)
cmd
.
Flags
()
.
StringP
(
"id"
,
"i"
,
""
,
"operating target id"
)
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
)
{
op
,
_
:=
cmd
.
Flags
()
.
Get
String
(
"operation"
)
op
,
_
:=
cmd
.
Flags
()
.
Get
Uint32
(
"operation"
)
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"
)
if
op
!=
"vote"
&&
op
!=
"quit"
&&
op
!=
"join"
{
fmt
.
Println
(
"operation should be one of join,quit,vote"
)
return
}
if
opAddr
==
""
{
fmt
.
Println
(
"addr parameter should not be null"
)
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
{
Execer
:
types
.
ExecName
(
pt
.
ParaX
),
ActionName
:
"NodeConfig"
,
...
...
@@ -305,11 +299,12 @@ func CreateNodeGroupApplyCmd() *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
.
Flags
()
.
StringP
(
"id"
,
"i"
,
""
,
"apply id for nodegroup "
)
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"
)
...
...
@@ -318,6 +313,7 @@ func addNodeGroupApplyCmdFlags(cmd *cobra.Command) {
func
nodeGroupApply
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
op
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"operation"
)
addrs
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addrs"
)
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
coins
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"coins_frozen"
)
if
op
==
0
||
op
>
3
{
...
...
@@ -329,7 +325,7 @@ func nodeGroupApply(cmd *cobra.Command, args []string) {
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
{
Execer
:
types
.
ExecName
(
pt
.
ParaX
),
ActionName
:
"NodeGroupConfig"
,
...
...
@@ -499,7 +495,7 @@ func nodeInfo(cmd *cobra.Command, args []string) {
Title
:
title
,
Addr
:
addr
,
}
var
res
pt
.
ParaNode
Addr
Status
var
res
pt
.
ParaNode
Id
Status
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"paracross.GetNodeStatus"
,
params
,
&
res
)
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
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"
,
""
)
crossTxReceipt
,
err
:=
a
.
execCrossTxs
(
commit
)
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 *
}
if
g
.
Prev
!=
nil
{
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
{
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
{
var
g
pt
.
ReceiptParaNodeVoteDone
err
:=
types
.
Decode
(
log
.
Log
,
&
g
)
...
...
@@ -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
)
{
var
set
types
.
LocalDBSet
for
_
,
log
:=
range
receiptData
.
Logs
{
if
log
.
Ty
==
pt
.
TyLogParaNodeGroupApply
||
log
.
Ty
==
pt
.
TyLogParaNodeGroupApprove
||
log
.
Ty
==
pt
.
TyLogParaNodeGroupQuit
{
if
log
.
Ty
==
pt
.
TyLogParaNodeGroupConfig
{
var
g
pt
.
ReceiptParaNodeGroupConfig
err
:=
types
.
Decode
(
log
.
Log
,
&
g
)
if
err
!=
nil
{
...
...
@@ -95,11 +94,11 @@ func (e *Paracross) ExecDelLocal_NodeGroupConfig(payload *pt.ParaNodeGroupConfig
}
if
g
.
Prev
!=
nil
{
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
{
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
...
...
plugin/dapp/paracross/executor/exec_local.go
View file @
09f609fb
...
...
@@ -67,11 +67,11 @@ func (e *Paracross) ExecLocal_NodeConfig(payload *pt.ParaNodeAddrConfig, tx *typ
}
if
g
.
Prev
!=
nil
{
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
{
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
)})
}
else
if
log
.
Ty
==
pt
.
TyLogParaNodeVoteDone
{
var
g
pt
.
ReceiptParaNodeVoteDone
...
...
@@ -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
)
{
var
set
types
.
LocalDBSet
for
_
,
log
:=
range
receiptData
.
Logs
{
if
log
.
Ty
==
pt
.
TyLogParaNodeGroupApply
||
log
.
Ty
==
pt
.
TyLogParaNodeGroupApprove
||
log
.
Ty
==
pt
.
TyLogParaNodeGroupQuit
||
log
.
Ty
==
pt
.
TyLogParaNodeGroupModify
{
if
log
.
Ty
==
pt
.
TyLogParaNodeGroupConfig
{
var
g
pt
.
ReceiptParaNodeGroupConfig
err
:=
types
.
Decode
(
log
.
Log
,
&
g
)
if
err
!=
nil
{
...
...
@@ -99,11 +98,11 @@ func (e *Paracross) ExecLocal_NodeGroupConfig(payload *pt.ParaNodeGroupConfig, t
}
if
g
.
Prev
!=
nil
{
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
{
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
...
...
plugin/dapp/paracross/executor/kv.go
View file @
09f609fb
...
...
@@ -102,22 +102,30 @@ func calcLocalAssetKey(hash []byte) []byte {
return
[]
byte
(
fmt
.
Sprintf
(
localAssetKey
+
"%s"
,
hash
))
}
func
calcLocalNodeTitleStatus
(
title
,
addr
string
,
status
int32
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
localNodeTitleStatus
+
"%s-%02d-%s"
,
title
,
status
,
addr
))
func
calcLocalNodeTitleStatus
(
title
string
,
status
int32
,
id
string
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
localNodeTitleStatus
+
"%s-%02d-%s"
,
title
,
status
,
id
))
}
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
{
return
[]
byte
(
fmt
.
Sprintf
(
localNodeTitleDone
+
"%s-%s"
,
title
,
addr
))
}
func
calcLocalNodeGroupStatusTitle
(
status
int32
,
title
string
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
localNodeGroupStatusTitle
+
"%02d-%s
"
,
status
,
title
))
func
calcLocalNodeGroupStatusTitle
(
status
int32
,
title
,
id
string
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
localNodeGroupStatusTitle
+
"%02d-%s
-%s"
,
status
,
title
,
id
))
}
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
if
in
==
nil
||
in
.
Title
==
""
||
in
.
Addr
==
""
{
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
{
return
nil
,
err
}
...
...
@@ -230,7 +234,7 @@ func listNodeStatus(db dbm.KVDB, prefix []byte) (types.Message, error) {
var
resp
pt
.
RespParacrossNodeAddrs
for
_
,
r
:=
range
res
{
var
st
pt
.
ParaNode
Addr
Status
var
st
pt
.
ParaNode
Id
Status
err
=
types
.
Decode
(
r
,
&
st
)
if
err
!=
nil
{
panic
(
err
)
...
...
plugin/dapp/paracross/executor/superaccount.go
View file @
09f609fb
...
...
@@ -34,25 +34,25 @@ func deepCopy(dst, src interface{}) error {
return
gob
.
NewDecoder
(
bytes
.
NewBuffer
(
buf
.
Bytes
()))
.
Decode
(
dst
)
}
func
getNodeAddr
(
db
dbm
.
KV
,
title
,
addr
string
)
(
*
pt
.
ParaNodeAddrStatus
,
error
)
{
func
getNodeAddr
(
db
dbm
.
KV
,
title
,
addr
string
)
(
*
pt
.
ParaNodeAddr
Id
Status
,
error
)
{
key
:=
calcParaNodeAddrKey
(
title
,
addr
)
val
,
err
:=
db
.
Get
(
key
)
if
err
!=
nil
{
return
nil
,
err
}
var
status
pt
.
ParaNodeAddrStatus
var
status
pt
.
ParaNodeAddr
Id
Status
err
=
types
.
Decode
(
val
,
&
status
)
return
&
status
,
err
}
func
getNodeId
(
db
dbm
.
KV
,
id
string
)
(
*
pt
.
ParaNode
Addr
Status
,
error
)
{
func
getNodeId
(
db
dbm
.
KV
,
id
string
)
(
*
pt
.
ParaNode
Id
Status
,
error
)
{
val
,
err
:=
getDb
(
db
,
[]
byte
(
id
))
if
err
!=
nil
{
return
nil
,
err
}
var
status
pt
.
ParaNode
Addr
Status
var
status
pt
.
ParaNode
Id
Status
err
=
types
.
Decode
(
val
,
&
status
)
return
&
status
,
err
}
...
...
@@ -88,10 +88,10 @@ func getNodeGroupId(db dbm.KV, id string) (*pt.ParaNodeGroupStatus, error) {
return
&
status
,
err
}
func
makeVoteDoneReceipt
(
config
*
pt
.
ParaNode
AddrConfig
,
totalCount
,
commitCount
,
most
int
,
pass
string
,
status
int32
)
*
types
.
Receipt
{
func
makeVoteDoneReceipt
(
config
*
pt
.
ParaNode
IdStatus
,
totalCount
,
commitCount
,
most
int
,
pass
string
,
status
int32
)
*
types
.
Receipt
{
log
:=
&
pt
.
ReceiptParaNodeVoteDone
{
Title
:
config
.
Title
,
TargetAddr
:
config
.
Addr
,
TargetAddr
:
config
.
Target
Addr
,
TotalNodes
:
int32
(
totalCount
),
TotalVote
:
int32
(
commitCount
),
MostVote
:
int32
(
most
),
...
...
@@ -111,10 +111,11 @@ func makeVoteDoneReceipt(config *pt.ParaNodeAddrConfig, totalCount, commitCount,
}
}
func
makeNodeConfigReceipt
(
addr
string
,
config
*
pt
.
ParaNodeAddrConfig
,
prev
,
current
*
pt
.
ParaNodeAddrStatus
)
*
types
.
Receipt
{
key
:=
calcParaNodeAddrKey
(
config
.
Title
,
config
.
Addr
)
func
makeNodeConfigReceipt
(
fromAddr
string
,
config
*
pt
.
ParaNodeAddrConfig
,
prev
,
current
*
pt
.
ParaNodeIdStatus
)
*
types
.
Receipt
{
key
:=
calcParaNodeAddrKey
(
current
.
Title
,
current
.
TargetAddr
)
val
:=
&
pt
.
ParaNodeAddrIdStatus
{
ProposalId
:
current
.
Id
}
log
:=
&
pt
.
ReceiptParaNodeConfig
{
Addr
:
a
ddr
,
Addr
:
fromA
ddr
,
Config
:
config
,
Prev
:
prev
,
Current
:
current
,
...
...
@@ -123,7 +124,7 @@ func makeNodeConfigReceipt(addr string, config *pt.ParaNodeAddrConfig, prev, cur
Ty
:
types
.
ExecOk
,
KV
:
[]
*
types
.
KeyValue
{
{
Key
:
[]
byte
(
current
.
Id
),
Value
:
types
.
Encode
(
current
)},
{
Key
:
key
,
Value
:
types
.
Encode
(
current
)},
{
Key
:
key
,
Value
:
types
.
Encode
(
val
)},
},
Logs
:
[]
*
types
.
ReceiptLog
{
{
...
...
@@ -134,7 +135,7 @@ func makeNodeConfigReceipt(addr string, config *pt.ParaNodeAddrConfig, prev, cur
}
}
func
makeNodeGroup
ApplyReceipt
(
addr
string
,
prev
,
current
*
pt
.
ParaNodeGroupStatus
,
logTy
int32
)
*
types
.
Receipt
{
func
makeNodeGroup
IdReceipt
(
addr
string
,
prev
,
current
*
pt
.
ParaNodeGroupStatus
)
*
types
.
Receipt
{
log
:=
&
pt
.
ReceiptParaNodeGroupConfig
{
Addr
:
addr
,
Prev
:
prev
,
...
...
@@ -147,14 +148,14 @@ func makeNodeGroupApplyReceipt(addr string, prev, current *pt.ParaNodeGroupStatu
},
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
logTy
,
Ty
:
pt
.
TyLogParaNodeGroupConfig
,
Log
:
types
.
Encode
(
log
),
},
},
}
}
func
makeParaNodeGroupStatusReceipt
(
addr
string
,
prev
,
current
*
pt
.
ParaNodeGroupStatus
,
logTy
int32
)
*
types
.
Receipt
{
func
makeParaNodeGroupStatusReceipt
(
title
string
,
addr
string
,
prev
,
current
*
pt
.
ParaNodeGroupStatus
)
*
types
.
Receipt
{
key
:=
calcParaNodeGroupStatusKey
(
title
)
log
:=
&
pt
.
ReceiptParaNodeGroupConfig
{
Addr
:
addr
,
...
...
@@ -168,7 +169,7 @@ func makeParaNodeGroupStatusReceipt(addr string, prev, current *pt.ParaNodeGroup
},
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
logTy
,
Ty
:
pt
.
TyLogParaNodeGroupStatusUpdate
,
Log
:
types
.
Encode
(
log
),
},
},
...
...
@@ -222,17 +223,17 @@ func (a *action) nodeJoin(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
}
s
tat
,
err
:=
getNodeAddr
(
a
.
db
,
config
.
Title
,
config
.
Addr
)
addrS
tat
,
err
:=
getNodeAddr
(
a
.
db
,
config
.
Title
,
config
.
Addr
)
if
err
!=
nil
{
if
!
isNotFound
(
err
)
{
return
nil
,
err
}
clog
.
Info
(
"first time add node addr"
,
"title"
,
config
.
Title
,
"addr"
,
config
.
Addr
)
stat
:=
&
pt
.
ParaNode
Addr
Status
{
stat
:=
&
pt
.
ParaNode
Id
Status
{
Id
:
calcParaNodeIdKey
(
config
.
Title
,
common
.
ToHex
(
a
.
txhash
)),
Status
:
pt
.
ParacrossNodeJoining
,
Title
:
config
.
Title
,
ApplyAddr
:
config
.
Addr
,
TargetAddr
:
config
.
Addr
,
FromAddr
:
a
.
fromaddr
,
Votes
:
&
pt
.
ParaNodeVoteDetail
{},
CoinsFrozen
:
config
.
CoinsFrozen
}
...
...
@@ -242,18 +243,19 @@ func (a *action) nodeJoin(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
return
receipt
,
nil
}
var
copyStat
pt
.
ParaNodeAddrStatus
stat
,
err
:=
getNodeId
(
a
.
db
,
addrStat
.
ProposalId
)
var
copyStat
pt
.
ParaNodeIdStatus
err
=
deepCopy
(
&
copyStat
,
stat
)
if
err
!=
nil
{
clog
.
Error
(
"nodeaccount.nodeJoin deep copy fail"
,
"copy"
,
copyStat
,
"stat"
,
stat
)
return
nil
,
err
}
if
stat
.
Status
==
pt
.
ParacrossNodeQuited
{
stat
=
&
pt
.
ParaNode
Addr
Status
{
stat
=
&
pt
.
ParaNode
Id
Status
{
Id
:
calcParaNodeIdKey
(
config
.
Title
,
common
.
ToHex
(
a
.
txhash
)),
Status
:
pt
.
ParacrossNodeJoining
,
Title
:
config
.
Title
,
ApplyAddr
:
config
.
Addr
,
TargetAddr
:
config
.
Addr
,
FromAddr
:
a
.
fromaddr
,
Votes
:
&
pt
.
ParaNodeVoteDetail
{},
CoinsFrozen
:
config
.
CoinsFrozen
}
...
...
@@ -278,12 +280,7 @@ func (a *action) nodeQuit(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
return
nil
,
errors
.
Wrapf
(
pt
.
ErrNodeNotForTheTitle
,
"config title:%s,id title:%s"
,
config
.
Title
,
stat
.
Title
)
}
if
stat
.
Status
==
pt
.
ParacrossNodeQuiting
||
stat
.
Status
==
pt
.
ParacrossNodeQuited
{
clog
.
Error
(
"nodeaccount.nodeQuit wrong status"
,
"status"
,
stat
)
return
nil
,
errors
.
Wrapf
(
pt
.
ErrParaUnSupportNodeOper
,
"nodeAddr %s was quit status:%d"
,
config
.
Addr
,
stat
.
Status
)
}
var
copyStat
pt
.
ParaNodeAddrStatus
var
copyStat
pt
.
ParaNodeIdStatus
err
=
deepCopy
(
&
copyStat
,
stat
)
if
err
!=
nil
{
clog
.
Error
(
"nodeaccount.nodeQuit deep copy fail"
,
"copy"
,
copyStat
,
"stat"
,
stat
)
...
...
@@ -294,12 +291,12 @@ func (a *action) nodeQuit(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"getNodes for title:%s"
,
config
.
Title
)
}
if
!
validNode
(
config
.
Addr
,
nodes
)
{
return
nil
,
errors
.
Wrapf
(
pt
.
ErrParaNodeAddrNotExisted
,
"nodeAddr not existed:%s"
,
config
.
Addr
)
if
!
validNode
(
stat
.
Target
Addr
,
nodes
)
{
return
nil
,
errors
.
Wrapf
(
pt
.
ErrParaNodeAddrNotExisted
,
"nodeAddr not existed:%s"
,
stat
.
Target
Addr
)
}
//不允许最后一个账户退出
if
len
(
nodes
)
==
1
{
return
nil
,
errors
.
Wrapf
(
pt
.
ErrParaNodeGroupLastAddr
,
"nodeAddr last one:%s"
,
config
.
Addr
)
return
nil
,
errors
.
Wrapf
(
pt
.
ErrParaNodeGroupLastAddr
,
"nodeAddr last one:%s"
,
stat
.
Target
Addr
)
}
stat
.
Status
=
pt
.
ParacrossNodeQuiting
...
...
@@ -328,7 +325,7 @@ func (a *action) nodeQuit(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
return
receipt
,
nil
}
return
nil
,
pt
.
ErrParaUnSupportNodeOper
return
nil
,
errors
.
Wrapf
(
pt
.
ErrParaUnSupportNodeOper
,
"nodeid %s was quit status:%d"
,
config
.
Id
,
stat
.
Status
)
}
...
...
@@ -342,10 +339,10 @@ func isSuperManager(addr string) bool {
return
false
}
func
getMostVote
(
stat
*
pt
.
ParaNode
AddrStatus
)
(
int
,
string
)
{
func
getMostVote
(
stat
*
pt
.
ParaNode
IdStatus
)
(
int
,
int
)
{
var
ok
,
nok
int
for
_
,
v
:=
range
stat
.
GetVotes
()
.
Votes
{
if
v
==
pt
.
ParaNodeVote
Yes
{
if
v
==
pt
.
ParaNodeVote
Str
[
pt
.
ParaNodeVoteYes
]
{
ok
++
}
else
{
nok
++
...
...
@@ -368,9 +365,7 @@ func (a *action) superManagerVoteProc(title string) error {
if
err
!=
nil
{
return
err
}
if
status
.
Status
!=
pt
.
ParacrossNodeGroupApprove
{
return
pt
.
ErrParaNodeGroupStatusWrong
}
confStopBlocks
:=
conf
.
GInt
(
"paraConsensusStopBlocks"
)
data
,
err
:=
a
.
exec
.
paracrossGetHeight
(
title
)
if
err
!=
nil
{
...
...
@@ -418,7 +413,7 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
return
nil
,
errors
.
Wrapf
(
pt
.
ErrNodeNotForTheTitle
,
"config title:%s,id title:%s"
,
config
.
Title
,
stat
.
Title
)
}
var
copyStat
pt
.
ParaNode
Addr
Status
var
copyStat
pt
.
ParaNode
Id
Status
err
=
deepCopy
(
&
copyStat
,
stat
)
if
err
!=
nil
{
clog
.
Error
(
"nodeaccount.nodevOTE deep copy fail"
,
"copy"
,
copyStat
,
"stat"
,
stat
)
...
...
@@ -430,10 +425,10 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
}
found
,
index
:=
hasVoted
(
stat
.
Votes
.
Addrs
,
a
.
fromaddr
)
if
found
{
stat
.
Votes
.
Votes
[
index
]
=
config
.
Value
stat
.
Votes
.
Votes
[
index
]
=
pt
.
ParaNodeVoteStr
[
config
.
Value
]
}
else
{
stat
.
Votes
.
Addrs
=
append
(
stat
.
Votes
.
Addrs
,
a
.
fromaddr
)
stat
.
Votes
.
Votes
=
append
(
stat
.
Votes
.
Votes
,
config
.
Value
)
stat
.
Votes
.
Votes
=
append
(
stat
.
Votes
.
Votes
,
pt
.
ParaNodeVoteStr
[
config
.
Value
]
)
}
most
,
vote
:=
getMostVote
(
stat
)
if
!
isCommitDone
(
stat
,
nodes
,
most
)
{
...
...
@@ -460,7 +455,7 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
if
vote
==
pt
.
ParaNodeVoteNo
{
// 对已经在group里面的node,直接投票remove,对正在申请中的adding or quiting状态保持不变,对quited的保持不变
if
stat
.
Status
==
pt
.
ParacrossNodeJoined
{
receiptGroup
,
err
=
unpdateNodeGroup
(
a
.
db
,
config
.
Title
,
config
.
Addr
,
false
)
receiptGroup
,
err
=
unpdateNodeGroup
(
a
.
db
,
config
.
Title
,
stat
.
Target
Addr
,
false
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -476,13 +471,13 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
}
}
else
{
if
stat
.
Status
==
pt
.
ParacrossNodeJoining
{
receiptGroup
,
err
=
unpdateNodeGroup
(
a
.
db
,
config
.
Title
,
config
.
Addr
,
true
)
receiptGroup
,
err
=
unpdateNodeGroup
(
a
.
db
,
config
.
Title
,
stat
.
Target
Addr
,
true
)
if
err
!=
nil
{
return
nil
,
err
}
stat
.
Status
=
pt
.
ParacrossNodeJoined
}
else
if
stat
.
Status
==
pt
.
ParacrossNodeQuiting
{
receiptGroup
,
err
=
unpdateNodeGroup
(
a
.
db
,
config
.
Title
,
config
.
Addr
,
false
)
receiptGroup
,
err
=
unpdateNodeGroup
(
a
.
db
,
config
.
Title
,
stat
.
Target
Addr
,
false
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -503,7 +498,7 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
receipt
.
KV
=
append
(
receipt
.
KV
,
receiptGroup
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
receiptGroup
.
Logs
...
)
}
receiptDone
:=
makeVoteDoneReceipt
(
config
,
len
(
nodes
),
len
(
stat
.
Votes
.
Addrs
),
most
,
vote
,
stat
.
Status
)
receiptDone
:=
makeVoteDoneReceipt
(
stat
,
len
(
nodes
),
len
(
stat
.
Votes
.
Addrs
),
most
,
pt
.
ParaNodeVoteStr
[
vote
]
,
stat
.
Status
)
receipt
.
KV
=
append
(
receipt
.
KV
,
receiptDone
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
receiptDone
.
Logs
...
)
return
receipt
,
nil
...
...
@@ -553,14 +548,6 @@ func unpdateNodeGroup(db dbm.KV, title, addr string, add bool) (*types.Receipt,
return
makeParaNodeGroupReceipt
(
title
,
&
copyItem
,
&
item
),
nil
}
func
(
a
*
action
)
checkConfig
(
title
string
)
error
{
if
!
validTitle
(
title
)
{
return
pt
.
ErrInvalidTitle
}
return
nil
}
func
getConfigAddrs
(
addr
string
)
[]
string
{
addr
=
strings
.
Trim
(
addr
,
" "
)
if
addr
==
""
{
...
...
@@ -673,12 +660,12 @@ func (a *action) nodeGroupApply(config *pt.ParaNodeGroupConfig) (*types.Receipt,
Id
:
calcParaNodeGroupIdKey
(
config
.
Title
,
common
.
ToHex
(
a
.
txhash
)),
Status
:
pt
.
ParacrossNodeGroupApply
,
Title
:
config
.
Title
,
ApplyAddrs
:
strings
.
Join
(
addrs
,
","
),
TargetAddrs
:
strings
.
Join
(
addrs
,
","
),
CoinsFrozen
:
config
.
CoinsFrozen
,
MainHeight
:
a
.
exec
.
GetMainHeight
(),
EmptyBlockInterval
:
config
.
EmptyBlockInterval
,
FromAddr
:
a
.
fromaddr
}
r
:=
makeNodeGroup
ApplyReceipt
(
a
.
fromaddr
,
nil
,
stat
,
pt
.
TyLogParaNodeGroupApply
)
r
:=
makeNodeGroup
IdReceipt
(
a
.
fromaddr
,
nil
,
stat
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
...
...
@@ -694,7 +681,7 @@ func (a *action) nodeGroupModify(config *pt.ParaNodeGroupConfig) (*types.Receipt
CoinsFrozen
:
config
.
CoinsFrozen
,
MainHeight
:
a
.
exec
.
GetMainHeight
(),
EmptyBlockInterval
:
config
.
EmptyBlockInterval
}
r
:=
makeNodeGroup
ApplyReceipt
(
a
.
fromaddr
,
nil
,
stat
,
pt
.
TyLogParaNodeGroupModify
)
r
:=
makeNodeGroup
IdReceipt
(
a
.
fromaddr
,
nil
,
stat
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
...
...
@@ -717,7 +704,7 @@ func (a *action) nodeGroupQuit(config *pt.ParaNodeGroupConfig) (*types.Receipt,
return
nil
,
pt
.
ErrParaNodeGroupStatusWrong
}
applyAddrs
:=
strings
.
Split
(
status
.
Apply
Addrs
,
","
)
applyAddrs
:=
strings
.
Split
(
status
.
Target
Addrs
,
","
)
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
}
//main chain
...
...
@@ -733,7 +720,7 @@ func (a *action) nodeGroupQuit(config *pt.ParaNodeGroupConfig) (*types.Receipt,
copyStat
:=
*
status
status
.
Status
=
pt
.
ParacrossNodeGroupQuit
r
:=
makeNodeGroup
ApplyReceipt
(
a
.
fromaddr
,
&
copyStat
,
status
,
pt
.
TyLogParaNodeGroupQuit
)
r
:=
makeNodeGroup
IdReceipt
(
a
.
fromaddr
,
&
copyStat
,
status
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
...
...
@@ -756,19 +743,19 @@ func (a *action) nodeGroupApproveModify(config *pt.ParaNodeGroupConfig, modify *
copyModify
:=
*
modify
modify
.
Status
=
pt
.
ParacrossNodeGroupApprove
r
:=
makeNodeGroup
ApplyReceipt
(
a
.
fromaddr
,
&
copyModify
,
modify
,
pt
.
TyLogParaNodeGroupApprove
)
r
:=
makeNodeGroup
IdReceipt
(
a
.
fromaddr
,
&
copyModify
,
modify
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
copyStat
:=
*
stat
//对已经approved group和addrs不再统一修改active&frozen改动的coins,因为可能有些addr已经退出group了,没退出的,退出时候按最初设置解冻
// 这里只修改参数,对后面再加入的节点起作用
copyStat
:=
*
stat
stat
.
Id
=
modify
.
Id
stat
.
CoinsFrozen
=
modify
.
CoinsFrozen
stat
.
EmptyBlockInterval
=
modify
.
EmptyBlockInterval
stat
.
MainHeight
=
a
.
exec
.
GetMainHeight
()
r
=
makeParaNodeGroupStatusReceipt
(
a
.
fromaddr
,
&
copyStat
,
stat
,
pt
.
TyLogParaNodeGroupStatusUpdate
)
r
=
makeParaNodeGroupStatusReceipt
(
config
.
Title
,
a
.
fromaddr
,
&
copyStat
,
stat
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
...
...
@@ -797,11 +784,11 @@ func (a *action) nodeGroupApproveApply(config *pt.ParaNodeGroupConfig, apply *pt
apply
.
Status
=
pt
.
ParacrossNodeGroupApprove
apply
.
MainHeight
=
a
.
exec
.
GetMainHeight
()
r
=
makeNodeGroup
ApplyReceipt
(
a
.
fromaddr
,
&
copyStat
,
apply
,
pt
.
TyLogParaNodeGroupApprove
)
r
=
makeNodeGroup
IdReceipt
(
a
.
fromaddr
,
&
copyStat
,
apply
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
r
=
makeParaNodeGroupStatusReceipt
(
a
.
fromaddr
,
nil
,
apply
,
pt
.
TyLogParaNodeGroupStatusUpdate
)
r
=
makeParaNodeGroupStatusReceipt
(
config
.
Title
,
a
.
fromaddr
,
nil
,
apply
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
...
...
@@ -816,33 +803,33 @@ func (a *action) nodeGroupApprove(config *pt.ParaNodeGroupConfig) (*types.Receip
return
nil
,
types
.
ErrNotAllow
}
IdStatus
,
err
:=
getNodeGroupId
(
a
.
db
,
config
.
Id
)
id
,
err
:=
getNodeGroupId
(
a
.
db
,
config
.
Id
)
if
err
!=
nil
{
return
nil
,
err
}
if
config
.
Title
!=
IdStatus
.
Title
{
return
nil
,
errors
.
Wrapf
(
pt
.
ErrNodeNotForTheTitle
,
"config title:%s,id title:%s"
,
config
.
Title
,
IdStatus
.
Title
)
if
config
.
Title
!=
id
.
Title
{
return
nil
,
errors
.
Wrapf
(
pt
.
ErrNodeNotForTheTitle
,
"config title:%s,id title:%s"
,
config
.
Title
,
id
.
Title
)
}
if
IdStatus
.
Status
==
pt
.
ParacrossNodeGroupModify
{
return
a
.
nodeGroupApproveModify
(
config
,
IdStatus
)
if
id
.
Status
==
pt
.
ParacrossNodeGroupModify
{
return
a
.
nodeGroupApproveModify
(
config
,
id
)
}
if
IdStatus
.
Status
==
pt
.
ParacrossNodeGroupApply
{
return
a
.
nodeGroupApproveApply
(
config
,
IdStatus
)
if
id
.
Status
==
pt
.
ParacrossNodeGroupApply
{
return
a
.
nodeGroupApproveApply
(
config
,
id
)
}
clog
.
Error
(
"nodeGroupApprove id wrong status"
,
"status"
,
IdStatus
.
Status
,
"id"
,
config
.
Id
)
clog
.
Error
(
"nodeGroupApprove id wrong status"
,
"status"
,
id
.
Status
,
"id"
,
config
.
Id
)
return
nil
,
pt
.
ErrParaNodeGroupStatusWrong
}
func
(
a
*
action
)
nodeGroupCreate
(
status
*
pt
.
ParaNodeGroupStatus
)
*
types
.
Receipt
{
nodes
:=
strings
.
Split
(
status
.
Apply
Addrs
,
","
)
nodes
:=
strings
.
Split
(
status
.
Target
Addrs
,
","
)
var
item
types
.
ConfigItem
key
:=
calcParaNodeGroupAddrsKey
(
t
itle
)
key
:=
calcParaNodeGroupAddrsKey
(
status
.
T
itle
)
item
.
Key
=
string
(
key
)
emptyValue
:=
&
types
.
ArrayConfig
{
Value
:
make
([]
string
,
0
)}
arr
:=
types
.
ConfigItem_Arr
{
Arr
:
emptyValue
}
...
...
@@ -850,15 +837,15 @@ func (a *action) nodeGroupCreate(status *pt.ParaNodeGroupStatus) *types.Receipt
item
.
GetArr
()
.
Value
=
append
(
item
.
GetArr
()
.
Value
,
nodes
...
)
item
.
Addr
=
a
.
fromaddr
receipt
:=
makeParaNodeGroupReceipt
(
t
itle
,
nil
,
&
item
)
receipt
:=
makeParaNodeGroupReceipt
(
status
.
T
itle
,
nil
,
&
item
)
//update addr status
for
i
,
addr
:=
range
nodes
{
stat
:=
&
pt
.
ParaNode
Addr
Status
{
stat
:=
&
pt
.
ParaNode
Id
Status
{
Id
:
status
.
Id
+
"-"
+
strconv
.
Itoa
(
i
),
Status
:
pt
.
ParacrossNodeJoined
,
Title
:
status
.
Title
,
ApplyAddr
:
addr
,
TargetAddr
:
addr
,
Votes
:
&
pt
.
ParaNodeVoteDetail
{
Addrs
:
[]
string
{
a
.
fromaddr
},
Votes
:
[]
string
{
"yes"
}},
CoinsFrozen
:
status
.
CoinsFrozen
,
FromAddr
:
status
.
FromAddr
}
...
...
@@ -923,7 +910,7 @@ func (a *action) NodeConfig(config *pt.ParaNodeAddrConfig) (*types.Receipt, erro
return
a
.
nodeQuit
(
config
)
}
else
if
config
.
Op
==
pt
.
ParaNodeVote
{
if
config
.
Id
==
""
{
if
config
.
Id
==
""
||
config
.
Value
>=
pt
.
ParaNodeVoteEnd
{
return
nil
,
types
.
ErrInvalidParam
}
return
a
.
nodeVote
(
config
)
...
...
plugin/dapp/paracross/executor/superaccount_test.go
View file @
09f609fb
...
...
@@ -108,7 +108,7 @@ func checkGroupApplyReceipt(suite *NodeManageTestSuite, receipt *types.Receipt)
err
:=
types
.
Decode
(
receipt
.
KV
[
0
]
.
Value
,
&
stat
)
assert
.
Nil
(
suite
.
T
(),
err
,
"decode ParaNodeAddrStatus failed"
)
//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
)
}
...
...
@@ -124,7 +124,7 @@ func checkGroupApproveReceipt(suite *NodeManageTestSuite, receipt *types.Receipt
err
:=
types
.
Decode
(
receipt
.
KV
[
len
-
1
]
.
Value
,
&
stat
)
assert
.
Nil
(
suite
.
T
(),
err
,
"decode ParaNodeAddrStatus failed"
)
//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
)
}
...
...
plugin/dapp/paracross/proto/paracross.proto
View file @
09f609fb
...
...
@@ -47,26 +47,30 @@ message ParacrossConsensusStatus {
string
consensBlockHash
=
4
;
}
message
ParaNodeAddrConfig
{
message
ParaNodeAddrConfig
{
string
title
=
1
;
string
op
=
2
;
uint32
op
=
2
;
string
id
=
3
;
string
addr
=
4
;
string
value
=
5
;
uint32
value
=
5
;
int64
coinsFrozen
=
6
;
}
message
ParaNodeVoteDetail
{
message
ParaNodeVoteDetail
{
repeated
string
addrs
=
1
;
repeated
string
votes
=
2
;
}
message
ParaNodeAddrStatus
{
message
ParaNodeAddrIdStatus
{
string
proposalId
=
1
;
}
message
ParaNodeIdStatus
{
string
id
=
1
;
int32
status
=
2
;
string
title
=
3
;
string
applyAddr
=
4
;
string
targetAddr
=
4
;
int64
coinsFrozen
=
5
;
ParaNodeVoteDetail
votes
=
6
;
string
fromAddr
=
7
;
...
...
@@ -76,8 +80,8 @@ message ParaNodeAddrStatus{
message
ReceiptParaNodeConfig
{
string
addr
=
1
;
ParaNodeAddrConfig
config
=
2
;
ParaNode
AddrStatus
prev
=
3
;
ParaNode
AddrStatus
current
=
4
;
ParaNode
IdStatus
prev
=
3
;
ParaNode
IdStatus
current
=
4
;
}
...
...
@@ -107,7 +111,7 @@ message ParaNodeGroupStatus {
string
id
=
1
;
int32
status
=
2
;
string
title
=
3
;
string
applyAddrs
=
4
;
string
targetAddrs
=
4
;
int64
coinsFrozen
=
5
;
uint32
emptyBlockInterval
=
6
;
int64
mainHeight
=
7
;
...
...
@@ -130,7 +134,7 @@ message ReqParacrossNodeInfo {
}
message
RespParacrossNodeAddrs
{
repeated
ParaNode
Addr
Status
addrs
=
1
;
repeated
ParaNode
Id
Status
addrs
=
1
;
}
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
}
// 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
data
,
err
:=
c
.
Query
(
pt
.
GetExecName
(),
"GetNodeAddrInfo"
,
&
r
)
if
err
!=
nil
{
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
nil
,
types
.
ErrDecode
...
...
plugin/dapp/paracross/types/paracross.go
View file @
09f609fb
...
...
@@ -40,10 +40,7 @@ const (
TyLogParaNodeConfig
=
657
TyLogParaNodeVoteDone
=
658
TyLogParaNodeGroupAddrsUpdate
=
659
TyLogParaNodeGroupApply
=
660
TyLogParaNodeGroupApprove
=
661
TyLogParaNodeGroupQuit
=
662
TyLogParaNodeGroupModify
=
663
TyLogParaNodeGroupConfig
=
660
TyLogParaNodeGroupStatusUpdate
=
664
)
...
...
@@ -92,14 +89,20 @@ const (
// node config op
const
(
ParaNodeJoin
=
"join"
ParaNodeQuit
=
"quit"
ParaNodeVote
=
"vote"
ParaNodeJoin
=
iota
+
1
ParaNodeVote
ParaNodeQuit
)
ParaNodeVoteYes
=
"yes"
ParaNodeVoteNo
=
"no"
const
(
ParaNodeVoteInvalid
=
iota
ParaNodeVoteYes
ParaNodeVoteNo
ParaNodeVoteEnd
)
var
ParaNodeVoteStr
=
[]
string
{
"invalid"
,
"yes"
,
"no"
}
const
(
// ParacrossNodeJoining apply for adding group
ParacrossNodeJoining
=
iota
+
1
...
...
@@ -183,6 +186,7 @@ func createRawCommitTx(status *ParacrossNodeStatus, name string, fee int64) (*ty
func
CreateRawNodeConfigTx
(
config
*
ParaNodeAddrConfig
)
(
*
types
.
Transaction
,
error
)
{
config
.
Title
=
types
.
GetTitle
()
config
.
Addr
=
strings
.
Trim
(
config
.
Addr
,
" "
)
config
.
Id
=
strings
.
Trim
(
config
.
Id
,
" "
)
action
:=
&
ParacrossAction
{
Ty
:
ParacrossActionNodeConfig
,
...
...
@@ -199,6 +203,7 @@ func CreateRawNodeConfigTx(config *ParaNodeAddrConfig) (*types.Transaction, erro
func
CreateRawNodeGroupApplyTx
(
apply
*
ParaNodeGroupConfig
)
(
*
types
.
Transaction
,
error
)
{
apply
.
Title
=
types
.
GetTitle
()
apply
.
EmptyBlockInterval
=
4
apply
.
Id
=
strings
.
Trim
(
apply
.
Id
,
" "
)
interval
:=
types
.
Conf
(
"config.consensus.sub.para"
)
.
GInt
(
"emptyBlockInterval"
)
if
interval
>
0
{
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 {
TyLogParaNodeConfig
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeConfig
{}),
Name
:
"LogParaNodeConfig"
},
TyLogParaNodeGroupAddrsUpdate
:
{
Ty
:
reflect
.
TypeOf
(
types
.
ReceiptConfig
{}),
Name
:
"LogParaNodeGroupAddrsUpdate"
},
TyLogParaNodeVoteDone
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeVoteDone
{}),
Name
:
"LogParaNodeVoteDone"
},
TyLogParaNodeGroupApply
:
{
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"
},
TyLogParaNodeGroupConfig
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeGroupConfig
{}),
Name
:
"LogParaNodeGroupApply"
},
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