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
f11abc5b
Commit
f11abc5b
authored
Jun 01, 2019
by
mdj33
Committed by
vipwzw
Jun 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add group id op
parent
7ce3ee2b
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
342 additions
and
261 deletions
+342
-261
action.go
plugin/dapp/paracross/executor/action.go
+1
-1
exec_local.go
plugin/dapp/paracross/executor/exec_local.go
+1
-1
kv.go
plugin/dapp/paracross/executor/kv.go
+17
-5
query.go
plugin/dapp/paracross/executor/query.go
+1
-1
superaccount.go
plugin/dapp/paracross/executor/superaccount.go
+256
-191
superaccount_test.go
plugin/dapp/paracross/executor/superaccount_test.go
+6
-6
paracross.proto
plugin/dapp/paracross/proto/paracross.proto
+31
-31
errors.go
plugin/dapp/paracross/types/errors.go
+0
-2
paracross.go
plugin/dapp/paracross/types/paracross.go
+14
-10
type.go
plugin/dapp/paracross/types/type.go
+15
-13
No files found.
plugin/dapp/paracross/executor/action.go
View file @
f11abc5b
...
@@ -77,7 +77,7 @@ func getConfigManageNodes(db dbm.KV, title string) (map[string]struct{}, []strin
...
@@ -77,7 +77,7 @@ func getConfigManageNodes(db dbm.KV, title string) (map[string]struct{}, []strin
}
}
func
getParacrossNodes
(
db
dbm
.
KV
,
title
string
)
(
map
[
string
]
struct
{},
[]
string
,
error
)
{
func
getParacrossNodes
(
db
dbm
.
KV
,
title
string
)
(
map
[
string
]
struct
{},
[]
string
,
error
)
{
key
:=
calcParaNodeGroupKey
(
title
)
key
:=
calcParaNodeGroup
Addrs
Key
(
title
)
return
getNodes
(
db
,
key
)
return
getNodes
(
db
,
key
)
}
}
...
...
plugin/dapp/paracross/executor/exec_local.go
View file @
f11abc5b
...
@@ -91,7 +91,7 @@ func (e *Paracross) ExecLocal_NodeGroupConfig(payload *pt.ParaNodeGroupConfig, t
...
@@ -91,7 +91,7 @@ func (e *Paracross) ExecLocal_NodeGroupConfig(payload *pt.ParaNodeGroupConfig, t
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
.
TyLogParaNodeGroupApply
||
log
.
Ty
==
pt
.
TyLogParaNodeGroupApprove
||
log
.
Ty
==
pt
.
TyLogParaNodeGroupQuit
{
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
{
...
...
plugin/dapp/paracross/executor/kv.go
View file @
f11abc5b
...
@@ -16,7 +16,9 @@ var (
...
@@ -16,7 +16,9 @@ var (
managerConfigNodes
string
//manager 合约配置的nodes
managerConfigNodes
string
//manager 合约配置的nodes
paraConfigNodes
string
//平行链自组织配置的nodes,最初是从manager同步过来
paraConfigNodes
string
//平行链自组织配置的nodes,最初是从manager同步过来
paraConfigNodeAddr
string
//平行链配置节点账户
paraConfigNodeAddr
string
//平行链配置节点账户
paraNodeGroupApplyAddrs
string
paraNodeGroupStatusAddrs
string
//正在申请的addrs
paraNodeId
string
paraNodeGroupId
string
localTx
string
localTx
string
localTitle
string
localTitle
string
localTitleHeight
string
localTitleHeight
string
...
@@ -32,7 +34,9 @@ func setPrefix() {
...
@@ -32,7 +34,9 @@ func setPrefix() {
managerConfigNodes
=
"paracross-nodes-"
managerConfigNodes
=
"paracross-nodes-"
paraConfigNodes
=
"mavl-paracross-nodes-title-"
paraConfigNodes
=
"mavl-paracross-nodes-title-"
paraConfigNodeAddr
=
"mavl-paracross-nodes-titleAddr-"
paraConfigNodeAddr
=
"mavl-paracross-nodes-titleAddr-"
paraNodeGroupApplyAddrs
=
"mavl-paracross-nodegroup-apply-title-"
paraNodeGroupStatusAddrs
=
"mavl-paracross-nodegroup-apply-title-"
paraNodeId
=
"mavl-paracross-title-nodeid-"
paraNodeGroupId
=
"mavl-paracross-title-nodegroupid-"
localTx
=
"LODB-paracross-titleHeightAddr-"
localTx
=
"LODB-paracross-titleHeightAddr-"
localTitle
=
"LODB-paracross-title-"
localTitle
=
"LODB-paracross-title-"
localTitleHeight
=
"LODB-paracross-titleHeight-"
localTitleHeight
=
"LODB-paracross-titleHeight-"
...
@@ -62,7 +66,7 @@ func calcManageConfigNodesKey(title string) []byte {
...
@@ -62,7 +66,7 @@ func calcManageConfigNodesKey(title string) []byte {
return
[]
byte
(
types
.
ManageKey
(
key
))
return
[]
byte
(
types
.
ManageKey
(
key
))
}
}
func
calcParaNodeGroupKey
(
title
string
)
[]
byte
{
func
calcParaNodeGroup
Addrs
Key
(
title
string
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
paraConfigNodes
+
"%s"
,
title
))
return
[]
byte
(
fmt
.
Sprintf
(
paraConfigNodes
+
"%s"
,
title
))
}
}
...
@@ -70,8 +74,16 @@ func calcParaNodeAddrKey(title string, addr string) []byte {
...
@@ -70,8 +74,16 @@ func calcParaNodeAddrKey(title string, addr string) []byte {
return
[]
byte
(
fmt
.
Sprintf
(
paraConfigNodeAddr
+
"%s-%s"
,
title
,
addr
))
return
[]
byte
(
fmt
.
Sprintf
(
paraConfigNodeAddr
+
"%s-%s"
,
title
,
addr
))
}
}
func
calcParaNodeGroupApplyKey
(
title
string
)
[]
byte
{
func
calcParaNodeGroupStatusKey
(
title
string
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
paraNodeGroupApplyAddrs
+
"%s"
,
title
))
return
[]
byte
(
fmt
.
Sprintf
(
paraNodeGroupStatusAddrs
+
"%s"
,
title
))
}
func
calcParaNodeIdKey
(
title
,
hash
string
)
string
{
return
fmt
.
Sprintf
(
paraNodeId
+
"%s-%s"
,
title
,
hash
)
}
func
calcParaNodeGroupIdKey
(
title
,
hash
string
)
string
{
return
fmt
.
Sprintf
(
paraNodeGroupId
+
"%s-%s"
,
title
,
hash
)
}
}
func
calcLocalTxKey
(
title
string
,
height
int64
,
addr
string
)
[]
byte
{
func
calcLocalTxKey
(
title
string
,
height
int64
,
addr
string
)
[]
byte
{
...
...
plugin/dapp/paracross/executor/query.go
View file @
f11abc5b
...
@@ -75,7 +75,7 @@ func (p *Paracross) Query_GetNodeGroupAddrs(in *pt.ReqParacrossNodeInfo) (types.
...
@@ -75,7 +75,7 @@ func (p *Paracross) Query_GetNodeGroupAddrs(in *pt.ReqParacrossNodeInfo) (types.
nodes
=
append
(
nodes
,
k
)
nodes
=
append
(
nodes
,
k
)
}
}
var
reply
types
.
ReplyConfig
var
reply
types
.
ReplyConfig
reply
.
Key
=
string
(
calcParaNodeGroupKey
(
in
.
GetTitle
()))
reply
.
Key
=
string
(
calcParaNodeGroup
Addrs
Key
(
in
.
GetTitle
()))
reply
.
Value
=
fmt
.
Sprint
(
nodes
)
reply
.
Value
=
fmt
.
Sprint
(
nodes
)
return
&
reply
,
nil
return
&
reply
,
nil
}
}
...
...
plugin/dapp/paracross/executor/superaccount.go
View file @
f11abc5b
...
@@ -10,6 +10,9 @@ import (
...
@@ -10,6 +10,9 @@ import (
"strings"
"strings"
"strconv"
"github.com/33cn/chain33/common"
dbm
"github.com/33cn/chain33/common/db"
dbm
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/system/dapp"
manager
"github.com/33cn/chain33/system/dapp/manage/types"
manager
"github.com/33cn/chain33/system/dapp/manage/types"
...
@@ -43,8 +46,19 @@ func getNodeAddr(db dbm.KV, title, addr string) (*pt.ParaNodeAddrStatus, error)
...
@@ -43,8 +46,19 @@ func getNodeAddr(db dbm.KV, title, addr string) (*pt.ParaNodeAddrStatus, error)
return
&
status
,
err
return
&
status
,
err
}
}
func
getNodeId
(
db
dbm
.
KV
,
id
string
)
(
*
pt
.
ParaNodeAddrStatus
,
error
)
{
val
,
err
:=
getDb
(
db
,
[]
byte
(
id
))
if
err
!=
nil
{
return
nil
,
err
}
var
status
pt
.
ParaNodeAddrStatus
err
=
types
.
Decode
(
val
,
&
status
)
return
&
status
,
err
}
func
getNodeGroupStatus
(
db
dbm
.
KV
,
title
string
)
(
*
pt
.
ParaNodeGroupStatus
,
error
)
{
func
getNodeGroupStatus
(
db
dbm
.
KV
,
title
string
)
(
*
pt
.
ParaNodeGroupStatus
,
error
)
{
key
:=
calcParaNodeGroup
Apply
Key
(
title
)
key
:=
calcParaNodeGroup
Status
Key
(
title
)
val
,
err
:=
db
.
Get
(
key
)
val
,
err
:=
db
.
Get
(
key
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -55,19 +69,23 @@ func getNodeGroupStatus(db dbm.KV, title string) (*pt.ParaNodeGroupStatus, error
...
@@ -55,19 +69,23 @@ func getNodeGroupStatus(db dbm.KV, title string) (*pt.ParaNodeGroupStatus, error
return
&
status
,
err
return
&
status
,
err
}
}
func
saveDb
(
db
dbm
.
KV
,
key
[]
byte
,
status
types
.
Message
)
error
{
func
getDb
(
db
dbm
.
KV
,
key
[]
byte
)
([]
byte
,
error
)
{
val
:=
types
.
Encode
(
status
)
val
,
err
:=
db
.
Get
(
key
)
return
db
.
Set
(
key
,
val
)
if
err
!=
nil
{
return
nil
,
err
}
return
val
,
nil
}
}
func
saveNodeAddr
(
db
dbm
.
KV
,
title
,
addr
string
,
status
types
.
Message
)
error
{
func
getNodeGroupId
(
db
dbm
.
KV
,
id
string
)
(
*
pt
.
ParaNodeGroupStatus
,
error
)
{
key
:=
calcParaNodeAddrKey
(
title
,
addr
)
val
,
err
:=
getDb
(
db
,
[]
byte
(
id
))
return
saveDb
(
db
,
key
,
status
)
if
err
!=
nil
{
}
return
nil
,
err
}
func
saveNodeGroup
(
db
dbm
.
KV
,
title
string
,
status
types
.
Message
)
error
{
var
status
pt
.
ParaNodeGroupStatus
key
:=
calcParaNodeGroupApplyKey
(
title
)
err
=
types
.
Decode
(
val
,
&
status
)
return
saveDb
(
db
,
key
,
status
)
return
&
status
,
err
}
}
func
makeVoteDoneReceipt
(
config
*
pt
.
ParaNodeAddrConfig
,
totalCount
,
commitCount
,
most
int
,
pass
string
,
status
int32
)
*
types
.
Receipt
{
func
makeVoteDoneReceipt
(
config
*
pt
.
ParaNodeAddrConfig
,
totalCount
,
commitCount
,
most
int
,
pass
string
,
status
int32
)
*
types
.
Receipt
{
...
@@ -104,6 +122,7 @@ func makeNodeConfigReceipt(addr string, config *pt.ParaNodeAddrConfig, prev, cur
...
@@ -104,6 +122,7 @@ func makeNodeConfigReceipt(addr string, config *pt.ParaNodeAddrConfig, prev, cur
return
&
types
.
Receipt
{
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
Ty
:
types
.
ExecOk
,
KV
:
[]
*
types
.
KeyValue
{
KV
:
[]
*
types
.
KeyValue
{
{
Key
:
[]
byte
(
current
.
Id
),
Value
:
types
.
Encode
(
current
)},
{
Key
:
key
,
Value
:
types
.
Encode
(
current
)},
{
Key
:
key
,
Value
:
types
.
Encode
(
current
)},
},
},
Logs
:
[]
*
types
.
ReceiptLog
{
Logs
:
[]
*
types
.
ReceiptLog
{
...
@@ -115,8 +134,28 @@ func makeNodeConfigReceipt(addr string, config *pt.ParaNodeAddrConfig, prev, cur
...
@@ -115,8 +134,28 @@ func makeNodeConfigReceipt(addr string, config *pt.ParaNodeAddrConfig, prev, cur
}
}
}
}
func
makeParaNodeGroupApplyReiceipt
(
title
,
addr
string
,
prev
,
current
*
pt
.
ParaNodeGroupStatus
,
logTy
int32
)
*
types
.
Receipt
{
func
makeNodeGroupApplyReceipt
(
addr
string
,
prev
,
current
*
pt
.
ParaNodeGroupStatus
,
logTy
int32
)
*
types
.
Receipt
{
key
:=
calcParaNodeGroupApplyKey
(
title
)
log
:=
&
pt
.
ReceiptParaNodeGroupConfig
{
Addr
:
addr
,
Prev
:
prev
,
Current
:
current
,
}
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
[]
*
types
.
KeyValue
{
{
Key
:
[]
byte
(
current
.
Id
),
Value
:
types
.
Encode
(
current
)},
},
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
logTy
,
Log
:
types
.
Encode
(
log
),
},
},
}
}
func
makeParaNodeGroupStatusReceipt
(
addr
string
,
prev
,
current
*
pt
.
ParaNodeGroupStatus
,
logTy
int32
)
*
types
.
Receipt
{
key
:=
calcParaNodeGroupStatusKey
(
title
)
log
:=
&
pt
.
ReceiptParaNodeGroupConfig
{
log
:=
&
pt
.
ReceiptParaNodeGroupConfig
{
Addr
:
addr
,
Addr
:
addr
,
Prev
:
prev
,
Prev
:
prev
,
...
@@ -136,8 +175,8 @@ func makeParaNodeGroupApplyReiceipt(title, addr string, prev, current *pt.ParaNo
...
@@ -136,8 +175,8 @@ func makeParaNodeGroupApplyReiceipt(title, addr string, prev, current *pt.ParaNo
}
}
}
}
func
makeParaNodeGroupRe
i
ceipt
(
title
string
,
prev
,
current
*
types
.
ConfigItem
)
*
types
.
Receipt
{
func
makeParaNodeGroupReceipt
(
title
string
,
prev
,
current
*
types
.
ConfigItem
)
*
types
.
Receipt
{
key
:=
calcParaNodeGroupKey
(
title
)
key
:=
calcParaNodeGroup
Addrs
Key
(
title
)
log
:=
&
types
.
ReceiptConfig
{
Prev
:
prev
,
Current
:
current
}
log
:=
&
types
.
ReceiptConfig
{
Prev
:
prev
,
Current
:
current
}
return
&
types
.
Receipt
{
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
Ty
:
types
.
ExecOk
,
...
@@ -146,7 +185,7 @@ func makeParaNodeGroupReiceipt(title string, prev, current *types.ConfigItem) *t
...
@@ -146,7 +185,7 @@ func makeParaNodeGroupReiceipt(title string, prev, current *types.ConfigItem) *t
},
},
Logs
:
[]
*
types
.
ReceiptLog
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
{
Ty
:
pt
.
TyLogParaNodeGroupUpdate
,
Ty
:
pt
.
TyLogParaNodeGroup
Addrs
Update
,
Log
:
types
.
Encode
(
log
),
Log
:
types
.
Encode
(
log
),
},
},
},
},
...
@@ -169,8 +208,6 @@ func (a *action) nodeJoin(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
...
@@ -169,8 +208,6 @@ func (a *action) nodeJoin(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
}
}
if
config
.
CoinsFrozen
<
nodeGroupStatus
.
CoinsFrozen
{
if
config
.
CoinsFrozen
<
nodeGroupStatus
.
CoinsFrozen
{
clog
.
Error
(
"nodeJoin coinfrozen not enough"
,
"title"
,
config
.
Title
,
"addr"
,
config
.
Addr
,
"config"
,
config
.
CoinsFrozen
,
"nodegroupConfig"
,
nodeGroupStatus
.
CoinsFrozen
)
return
nil
,
errors
.
Wrapf
(
pt
.
ErrParaNodeGroupFrozenCoinsNotEnough
,
return
nil
,
errors
.
Wrapf
(
pt
.
ErrParaNodeGroupFrozenCoinsNotEnough
,
"coinFrozen not enough:%d,expected:%d"
,
config
.
CoinsFrozen
,
nodeGroupStatus
.
CoinsFrozen
)
"coinFrozen not enough:%d,expected:%d"
,
config
.
CoinsFrozen
,
nodeGroupStatus
.
CoinsFrozen
)
}
}
...
@@ -191,13 +228,14 @@ func (a *action) nodeJoin(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
...
@@ -191,13 +228,14 @@ func (a *action) nodeJoin(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
return
nil
,
err
return
nil
,
err
}
}
clog
.
Info
(
"first time add node addr"
,
"title"
,
config
.
Title
,
"addr"
,
config
.
Addr
)
clog
.
Info
(
"first time add node addr"
,
"title"
,
config
.
Title
,
"addr"
,
config
.
Addr
)
stat
:=
&
pt
.
ParaNodeAddrStatus
{
Status
:
pt
.
ParacrossNodeAdding
,
stat
:=
&
pt
.
ParaNodeAddrStatus
{
Id
:
calcParaNodeIdKey
(
config
.
Title
,
common
.
ToHex
(
a
.
txhash
)),
Status
:
pt
.
ParacrossNodeJoining
,
Title
:
config
.
Title
,
Title
:
config
.
Title
,
ApplyAddr
:
config
.
Addr
,
ApplyAddr
:
config
.
Addr
,
FromAddr
:
a
.
fromaddr
,
FromAddr
:
a
.
fromaddr
,
Votes
:
&
pt
.
ParaNodeVoteDetail
{},
Votes
:
&
pt
.
ParaNodeVoteDetail
{},
CoinsFrozen
:
config
.
CoinsFrozen
}
CoinsFrozen
:
config
.
CoinsFrozen
}
saveNodeAddr
(
a
.
db
,
config
.
Title
,
config
.
Addr
,
stat
)
r
:=
makeNodeConfigReceipt
(
a
.
fromaddr
,
config
,
nil
,
stat
)
r
:=
makeNodeConfigReceipt
(
a
.
fromaddr
,
config
,
nil
,
stat
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
...
@@ -210,36 +248,34 @@ func (a *action) nodeJoin(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
...
@@ -210,36 +248,34 @@ func (a *action) nodeJoin(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
clog
.
Error
(
"nodeaccount.nodeJoin deep copy fail"
,
"copy"
,
copyStat
,
"stat"
,
stat
)
clog
.
Error
(
"nodeaccount.nodeJoin deep copy fail"
,
"copy"
,
copyStat
,
"stat"
,
stat
)
return
nil
,
err
return
nil
,
err
}
}
if
stat
.
Status
!=
pt
.
ParacrossNodeQuited
{
if
stat
.
Status
==
pt
.
ParacrossNodeQuited
{
clog
.
Error
(
"nodeaccount.nodeJoin key exist"
,
"addr"
,
config
.
Addr
,
"status"
,
stat
)
stat
=
&
pt
.
ParaNodeAddrStatus
{
return
nil
,
pt
.
ErrParaNodeAddrExisted
Id
:
calcParaNodeIdKey
(
config
.
Title
,
common
.
ToHex
(
a
.
txhash
)),
}
Status
:
pt
.
ParacrossNodeJoining
,
stat
=
&
pt
.
ParaNodeAddrStatus
{
Title
:
config
.
Title
,
Status
:
pt
.
ParacrossNodeAdding
,
ApplyAddr
:
config
.
Addr
,
Title
:
config
.
Title
,
FromAddr
:
a
.
fromaddr
,
ApplyAddr
:
config
.
Addr
,
Votes
:
&
pt
.
ParaNodeVoteDetail
{},
FromAddr
:
a
.
fromaddr
,
CoinsFrozen
:
config
.
CoinsFrozen
}
Votes
:
&
pt
.
ParaNodeVoteDetail
{},
r
:=
makeNodeConfigReceipt
(
a
.
fromaddr
,
config
,
&
copyStat
,
stat
)
CoinsFrozen
:
config
.
CoinsFrozen
}
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
saveNodeAddr
(
a
.
db
,
config
.
Title
,
config
.
Addr
,
stat
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
r
:=
makeNodeConfigReceipt
(
a
.
fromaddr
,
config
,
&
copyStat
,
stat
)
return
receipt
,
nil
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
}
return
receipt
,
nil
clog
.
Error
(
"nodeaccount.nodeJoin key exist"
,
"addr"
,
config
.
Addr
,
"status"
,
stat
)
return
nil
,
pt
.
ErrParaNodeAddrExisted
}
}
func
(
a
*
action
)
nodeQuit
(
config
*
pt
.
ParaNodeAddrConfig
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
nodeQuit
(
config
*
pt
.
ParaNodeAddrConfig
)
(
*
types
.
Receipt
,
error
)
{
stat
,
err
:=
getNode
Addr
(
a
.
db
,
config
.
Title
,
config
.
Addr
)
stat
,
err
:=
getNode
Id
(
a
.
db
,
config
.
Id
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
//代替别人退出或者自己退出都允许,但代替别人退出时候创建账户也必须匹配
if
config
.
Title
!=
stat
.
Title
{
if
a
.
fromaddr
!=
stat
.
FromAddr
&&
a
.
fromaddr
!=
config
.
Addr
{
return
nil
,
errors
.
Wrapf
(
pt
.
ErrNodeNotForTheTitle
,
"config title:%s,id title:%s"
,
config
.
Title
,
stat
.
Title
)
clog
.
Error
(
"nodeaccount.nodeQuit wrong addr"
,
"createAddr"
,
stat
.
FromAddr
,
"confAddr"
,
config
.
Addr
,
"fromAddr"
,
a
.
fromaddr
)
return
nil
,
types
.
ErrNotAllow
}
}
if
stat
.
Status
==
pt
.
ParacrossNodeQuiting
||
stat
.
Status
==
pt
.
ParacrossNodeQuited
{
if
stat
.
Status
==
pt
.
ParacrossNodeQuiting
||
stat
.
Status
==
pt
.
ParacrossNodeQuited
{
...
@@ -247,7 +283,13 @@ func (a *action) nodeQuit(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
...
@@ -247,7 +283,13 @@ func (a *action) nodeQuit(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
return
nil
,
errors
.
Wrapf
(
pt
.
ErrParaUnSupportNodeOper
,
"nodeAddr %s was quit status:%d"
,
config
.
Addr
,
stat
.
Status
)
return
nil
,
errors
.
Wrapf
(
pt
.
ErrParaUnSupportNodeOper
,
"nodeAddr %s was quit status:%d"
,
config
.
Addr
,
stat
.
Status
)
}
}
if
stat
.
Status
==
pt
.
ParacrossNodeAdded
{
var
copyStat
pt
.
ParaNodeAddrStatus
err
=
deepCopy
(
&
copyStat
,
stat
)
if
err
!=
nil
{
clog
.
Error
(
"nodeaccount.nodeQuit deep copy fail"
,
"copy"
,
copyStat
,
"stat"
,
stat
)
return
nil
,
err
}
if
stat
.
Status
==
pt
.
ParacrossNodeJoined
{
nodes
,
_
,
err
:=
getParacrossNodes
(
a
.
db
,
config
.
Title
)
nodes
,
_
,
err
:=
getParacrossNodes
(
a
.
db
,
config
.
Title
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"getNodes for title:%s"
,
config
.
Title
)
return
nil
,
errors
.
Wrapf
(
err
,
"getNodes for title:%s"
,
config
.
Title
)
...
@@ -259,40 +301,34 @@ func (a *action) nodeQuit(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
...
@@ -259,40 +301,34 @@ func (a *action) nodeQuit(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
if
len
(
nodes
)
==
1
{
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"
,
config
.
Addr
)
}
}
}
var
copyStat
pt
.
ParaNodeAddrStatus
err
=
deepCopy
(
&
copyStat
,
stat
)
if
err
!=
nil
{
clog
.
Error
(
"nodeaccount.nodeQuit deep copy fail"
,
"copy"
,
copyStat
,
"stat"
,
stat
)
return
nil
,
err
}
if
stat
.
Status
==
pt
.
ParacrossNodeAdded
{
stat
.
Status
=
pt
.
ParacrossNodeQuiting
stat
.
Status
=
pt
.
ParacrossNodeQuiting
stat
.
Votes
=
&
pt
.
ParaNodeVoteDetail
{}
stat
.
Votes
=
&
pt
.
ParaNodeVoteDetail
{}
saveNodeAddr
(
a
.
db
,
config
.
Title
,
config
.
Addr
,
stat
)
return
makeNodeConfigReceipt
(
a
.
fromaddr
,
config
,
&
copyStat
,
stat
),
nil
return
makeNodeConfigReceipt
(
a
.
fromaddr
,
config
,
&
copyStat
,
stat
),
nil
}
}
//still adding status, quit directly
if
stat
.
Status
==
pt
.
ParacrossNodeJoining
{
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
}
//still adding status, quit directly
if
!
types
.
IsPara
()
{
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
}
r
,
err
:=
a
.
nodeGroupCoinsActive
(
stat
.
FromAddr
,
stat
.
CoinsFrozen
,
1
)
if
!
types
.
IsPara
()
{
if
err
!=
nil
{
r
,
err
:=
a
.
nodeGroupCoinsActive
(
stat
.
FromAddr
,
stat
.
CoinsFrozen
,
1
)
return
nil
,
err
if
err
!=
nil
{
return
nil
,
err
}
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
}
}
stat
.
Status
=
pt
.
ParacrossNodeQuited
stat
.
Votes
=
&
pt
.
ParaNodeVoteDetail
{}
r
:=
makeNodeConfigReceipt
(
a
.
fromaddr
,
config
,
&
copyStat
,
stat
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
}
stat
.
Status
=
pt
.
ParacrossNodeQuited
return
receipt
,
nil
stat
.
Votes
=
&
pt
.
ParaNodeVoteDetail
{}
}
saveNodeAddr
(
a
.
db
,
config
.
Title
,
config
.
Addr
,
stat
)
r
:=
makeNodeConfigReceipt
(
a
.
fromaddr
,
config
,
&
copyStat
,
stat
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
return
receipt
,
nil
return
nil
,
pt
.
ErrParaUnSupportNodeOper
}
}
...
@@ -373,11 +409,15 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
...
@@ -373,11 +409,15 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
return
nil
,
errors
.
Wrapf
(
pt
.
ErrNodeNotForTheTitle
,
"not validNode:%s"
,
a
.
fromaddr
)
return
nil
,
errors
.
Wrapf
(
pt
.
ErrNodeNotForTheTitle
,
"not validNode:%s"
,
a
.
fromaddr
)
}
}
stat
,
err
:=
getNode
Addr
(
a
.
db
,
config
.
Title
,
config
.
Addr
)
stat
,
err
:=
getNode
Id
(
a
.
db
,
config
.
Id
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
config
.
Title
!=
stat
.
Title
{
return
nil
,
errors
.
Wrapf
(
pt
.
ErrNodeNotForTheTitle
,
"config title:%s,id title:%s"
,
config
.
Title
,
stat
.
Title
)
}
var
copyStat
pt
.
ParaNodeAddrStatus
var
copyStat
pt
.
ParaNodeAddrStatus
err
=
deepCopy
(
&
copyStat
,
stat
)
err
=
deepCopy
(
&
copyStat
,
stat
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -411,7 +451,6 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
...
@@ -411,7 +451,6 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
//超级用户投yes票,共识停止了一定高度就可以通过,防止当前所有授权节点都忘掉私钥场景
//超级用户投yes票,共识停止了一定高度就可以通过,防止当前所有授权节点都忘掉私钥场景
if
!
(
superManagerPass
&&
most
>
0
&&
vote
==
pt
.
ParaNodeVoteYes
)
{
if
!
(
superManagerPass
&&
most
>
0
&&
vote
==
pt
.
ParaNodeVoteYes
)
{
saveNodeAddr
(
a
.
db
,
config
.
Title
,
config
.
Addr
,
stat
)
return
makeNodeConfigReceipt
(
a
.
fromaddr
,
config
,
&
copyStat
,
stat
),
nil
return
makeNodeConfigReceipt
(
a
.
fromaddr
,
config
,
&
copyStat
,
stat
),
nil
}
}
}
}
...
@@ -420,7 +459,7 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
...
@@ -420,7 +459,7 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
var
receiptGroup
*
types
.
Receipt
var
receiptGroup
*
types
.
Receipt
if
vote
==
pt
.
ParaNodeVoteNo
{
if
vote
==
pt
.
ParaNodeVoteNo
{
// 对已经在group里面的node,直接投票remove,对正在申请中的adding or quiting状态保持不变,对quited的保持不变
// 对已经在group里面的node,直接投票remove,对正在申请中的adding or quiting状态保持不变,对quited的保持不变
if
stat
.
Status
==
pt
.
ParacrossNode
Add
ed
{
if
stat
.
Status
==
pt
.
ParacrossNode
Join
ed
{
receiptGroup
,
err
=
unpdateNodeGroup
(
a
.
db
,
config
.
Title
,
config
.
Addr
,
false
)
receiptGroup
,
err
=
unpdateNodeGroup
(
a
.
db
,
config
.
Title
,
config
.
Addr
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -436,12 +475,12 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
...
@@ -436,12 +475,12 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
}
}
}
}
}
else
{
}
else
{
if
stat
.
Status
==
pt
.
ParacrossNode
Add
ing
{
if
stat
.
Status
==
pt
.
ParacrossNode
Join
ing
{
receiptGroup
,
err
=
unpdateNodeGroup
(
a
.
db
,
config
.
Title
,
config
.
Addr
,
true
)
receiptGroup
,
err
=
unpdateNodeGroup
(
a
.
db
,
config
.
Title
,
config
.
Addr
,
true
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
stat
.
Status
=
pt
.
ParacrossNode
Add
ed
stat
.
Status
=
pt
.
ParacrossNode
Join
ed
}
else
if
stat
.
Status
==
pt
.
ParacrossNodeQuiting
{
}
else
if
stat
.
Status
==
pt
.
ParacrossNodeQuiting
{
receiptGroup
,
err
=
unpdateNodeGroup
(
a
.
db
,
config
.
Title
,
config
.
Addr
,
false
)
receiptGroup
,
err
=
unpdateNodeGroup
(
a
.
db
,
config
.
Title
,
config
.
Addr
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -459,7 +498,6 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
...
@@ -459,7 +498,6 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
}
}
}
}
}
}
saveNodeAddr
(
a
.
db
,
config
.
Title
,
config
.
Addr
,
stat
)
receipt
:=
makeNodeConfigReceipt
(
a
.
fromaddr
,
config
,
&
copyStat
,
stat
)
receipt
:=
makeNodeConfigReceipt
(
a
.
fromaddr
,
config
,
&
copyStat
,
stat
)
if
receiptGroup
!=
nil
{
if
receiptGroup
!=
nil
{
receipt
.
KV
=
append
(
receipt
.
KV
,
receiptGroup
.
KV
...
)
receipt
.
KV
=
append
(
receipt
.
KV
,
receiptGroup
.
KV
...
)
...
@@ -475,7 +513,7 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
...
@@ -475,7 +513,7 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
func
unpdateNodeGroup
(
db
dbm
.
KV
,
title
,
addr
string
,
add
bool
)
(
*
types
.
Receipt
,
error
)
{
func
unpdateNodeGroup
(
db
dbm
.
KV
,
title
,
addr
string
,
add
bool
)
(
*
types
.
Receipt
,
error
)
{
var
item
types
.
ConfigItem
var
item
types
.
ConfigItem
key
:=
calcParaNodeGroupKey
(
title
)
key
:=
calcParaNodeGroup
Addrs
Key
(
title
)
value
,
err
:=
db
.
Get
(
key
)
value
,
err
:=
db
.
Get
(
key
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -512,7 +550,7 @@ func unpdateNodeGroup(db dbm.KV, title, addr string, add bool) (*types.Receipt,
...
@@ -512,7 +550,7 @@ func unpdateNodeGroup(db dbm.KV, title, addr string, add bool) (*types.Receipt,
}
}
}
}
return
makeParaNodeGroupRe
i
ceipt
(
title
,
&
copyItem
,
&
item
),
nil
return
makeParaNodeGroupReceipt
(
title
,
&
copyItem
,
&
item
),
nil
}
}
func
(
a
*
action
)
checkConfig
(
title
string
)
error
{
func
(
a
*
action
)
checkConfig
(
title
string
)
error
{
...
@@ -523,7 +561,7 @@ func (a *action) checkConfig(title string) error {
...
@@ -523,7 +561,7 @@ func (a *action) checkConfig(title string) error {
return
nil
return
nil
}
}
func
get
AddrGroup
(
addr
string
)
[]
string
{
func
get
ConfigAddrs
(
addr
string
)
[]
string
{
addr
=
strings
.
Trim
(
addr
,
" "
)
addr
=
strings
.
Trim
(
addr
,
" "
)
if
addr
==
""
{
if
addr
==
""
{
return
nil
return
nil
...
@@ -549,7 +587,7 @@ func getAddrGroup(addr string) []string {
...
@@ -549,7 +587,7 @@ func getAddrGroup(addr string) []string {
}
}
func
(
a
*
action
)
checkNodeGroupExist
(
title
string
)
error
{
func
(
a
*
action
)
checkNodeGroupExist
(
title
string
)
error
{
key
:=
calcParaNodeGroupKey
(
title
)
key
:=
calcParaNodeGroup
Addrs
Key
(
title
)
value
,
err
:=
a
.
db
.
Get
(
key
)
value
,
err
:=
a
.
db
.
Get
(
key
)
if
err
!=
nil
&&
!
isNotFound
(
err
)
{
if
err
!=
nil
&&
!
isNotFound
(
err
)
{
return
err
return
err
...
@@ -613,16 +651,7 @@ func (a *action) nodeGroupCoinsActive(createAddr string, configCoinsFrozen int64
...
@@ -613,16 +651,7 @@ func (a *action) nodeGroupCoinsActive(createAddr string, configCoinsFrozen int64
// NodeGroupApply
// NodeGroupApply
func
(
a
*
action
)
nodeGroupApply
(
config
*
pt
.
ParaNodeGroupConfig
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
nodeGroupApply
(
config
*
pt
.
ParaNodeGroupConfig
)
(
*
types
.
Receipt
,
error
)
{
status
,
err
:=
getNodeGroupStatus
(
a
.
db
,
config
.
Title
)
addrs
:=
getConfigAddrs
(
config
.
Addrs
)
if
err
!=
nil
&&
!
isNotFound
(
err
)
{
return
nil
,
err
}
if
status
!=
nil
&&
status
.
Status
!=
pt
.
ParacrossNodeGroupQuit
{
clog
.
Error
(
"node group apply exist"
,
"status"
,
status
.
Status
)
return
nil
,
pt
.
ErrParaNodeGroupExisted
}
addrs
:=
getAddrGroup
(
config
.
Addrs
)
if
len
(
addrs
)
==
0
{
if
len
(
addrs
)
==
0
{
clog
.
Error
(
"node group apply addrs null"
,
"addrs"
,
config
.
Addrs
)
clog
.
Error
(
"node group apply addrs null"
,
"addrs"
,
config
.
Addrs
)
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
...
@@ -640,15 +669,32 @@ func (a *action) nodeGroupApply(config *pt.ParaNodeGroupConfig) (*types.Receipt,
...
@@ -640,15 +669,32 @@ func (a *action) nodeGroupApply(config *pt.ParaNodeGroupConfig) (*types.Receipt,
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
}
}
stat
:=
&
pt
.
ParaNodeGroupStatus
{
Status
:
pt
.
ParacrossNodeGroupApply
,
stat
:=
&
pt
.
ParaNodeGroupStatus
{
Id
:
calcParaNodeGroupIdKey
(
config
.
Title
,
common
.
ToHex
(
a
.
txhash
)),
Status
:
pt
.
ParacrossNodeGroupApply
,
Title
:
config
.
Title
,
Title
:
config
.
Title
,
ApplyAddr
:
strings
.
Join
(
addrs
,
","
),
ApplyAddr
s
:
strings
.
Join
(
addrs
,
","
),
CoinsFrozen
:
config
.
CoinsFrozen
,
CoinsFrozen
:
config
.
CoinsFrozen
,
MainHeight
:
a
.
exec
.
GetMainHeight
(),
MainHeight
:
a
.
exec
.
GetMainHeight
(),
EmptyBlockInterval
:
config
.
EmptyBlockInterval
,
EmptyBlockInterval
:
config
.
EmptyBlockInterval
,
FromAddr
:
a
.
fromaddr
}
FromAddr
:
a
.
fromaddr
}
saveNodeGroup
(
a
.
db
,
config
.
Title
,
stat
)
r
:=
makeNodeGroupApplyReceipt
(
a
.
fromaddr
,
nil
,
stat
,
pt
.
TyLogParaNodeGroupApply
)
r
:=
makeParaNodeGroupApplyReiceipt
(
config
.
Title
,
a
.
fromaddr
,
status
,
stat
,
pt
.
TyLogParaNodeGroupApply
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
return
receipt
,
nil
}
func
(
a
*
action
)
nodeGroupModify
(
config
*
pt
.
ParaNodeGroupConfig
)
(
*
types
.
Receipt
,
error
)
{
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
}
stat
:=
&
pt
.
ParaNodeGroupStatus
{
Id
:
calcParaNodeGroupIdKey
(
config
.
Title
,
common
.
ToHex
(
a
.
txhash
)),
Status
:
pt
.
ParacrossNodeGroupModify
,
Title
:
config
.
Title
,
CoinsFrozen
:
config
.
CoinsFrozen
,
MainHeight
:
a
.
exec
.
GetMainHeight
(),
EmptyBlockInterval
:
config
.
EmptyBlockInterval
}
r
:=
makeNodeGroupApplyReceipt
(
a
.
fromaddr
,
nil
,
stat
,
pt
.
TyLogParaNodeGroupModify
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
...
@@ -656,29 +702,27 @@ func (a *action) nodeGroupApply(config *pt.ParaNodeGroupConfig) (*types.Receipt,
...
@@ -656,29 +702,27 @@ func (a *action) nodeGroupApply(config *pt.ParaNodeGroupConfig) (*types.Receipt,
}
}
func
(
a
*
action
)
nodeGroupQuit
(
config
*
pt
.
ParaNodeGroupConfig
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
nodeGroupQuit
(
config
*
pt
.
ParaNodeGroupConfig
)
(
*
types
.
Receipt
,
error
)
{
status
,
err
:=
getNodeGroup
Status
(
a
.
db
,
config
.
Title
)
status
,
err
:=
getNodeGroup
Id
(
a
.
db
,
config
.
Id
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
status
.
Status
!=
pt
.
ParacrossNodeGroupApply
{
clog
.
Error
(
"node group apply exist"
,
"status"
,
status
.
Status
)
return
nil
,
pt
.
ErrParaNodeGroupStatusWrong
}
if
status
.
FromAddr
!=
a
.
fromaddr
{
if
config
.
Title
!=
status
.
Title
{
clog
.
Error
(
"node group create addr err"
,
"createAddr"
,
status
.
FromAddr
,
"currAddr"
,
a
.
fromaddr
)
return
nil
,
errors
.
Wrapf
(
pt
.
ErrNodeNotForTheTitle
,
"config title:%s,id title:%s"
,
config
.
Title
,
status
.
Title
)
return
nil
,
types
.
ErrNotAllow
}
}
applyAddrs
,
err
:=
checkNodeGroupAddrsMatch
(
status
.
ApplyAddr
,
config
.
Addrs
)
//approved or quited
if
err
!=
nil
{
if
status
.
Status
!=
pt
.
ParacrossNodeGroupApply
{
return
nil
,
err
clog
.
Error
(
"node group apply not apply"
,
"status"
,
status
.
Status
)
return
nil
,
pt
.
ErrParaNodeGroupStatusWrong
}
}
applyAddrs
:=
strings
.
Split
(
status
.
ApplyAddrs
,
","
)
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
}
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
}
//main chain
//main chain
if
!
types
.
IsPara
()
{
if
!
types
.
IsPara
()
{
r
,
err
:=
a
.
nodeGroupCoinsActive
(
a
.
froma
ddr
,
status
.
CoinsFrozen
,
int64
(
len
(
applyAddrs
)))
r
,
err
:=
a
.
nodeGroupCoinsActive
(
status
.
FromA
ddr
,
status
.
CoinsFrozen
,
int64
(
len
(
applyAddrs
)))
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -686,49 +730,82 @@ func (a *action) nodeGroupQuit(config *pt.ParaNodeGroupConfig) (*types.Receipt,
...
@@ -686,49 +730,82 @@ func (a *action) nodeGroupQuit(config *pt.ParaNodeGroupConfig) (*types.Receipt,
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
}
}
stat
:=
&
pt
.
ParaNodeGroupStatus
{
Status
:
pt
.
ParacrossNodeGroupQuit
,
copyStat
:=
*
status
Title
:
config
.
Title
,
status
.
Status
=
pt
.
ParacrossNodeGroupQuit
ApplyAddr
:
status
.
ApplyAddr
,
CoinsFrozen
:
status
.
CoinsFrozen
,
r
:=
makeNodeGroupApplyReceipt
(
a
.
fromaddr
,
&
copyStat
,
status
,
pt
.
TyLogParaNodeGroupQuit
)
MainHeight
:
a
.
exec
.
GetMainHeight
(),
EmptyBlockInterval
:
status
.
EmptyBlockInterval
,
FromAddr
:
a
.
fromaddr
}
saveNodeGroup
(
a
.
db
,
config
.
Title
,
stat
)
r
:=
makeParaNodeGroupApplyReiceipt
(
config
.
Title
,
a
.
fromaddr
,
status
,
stat
,
pt
.
TyLogParaNodeGroupQuit
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
return
receipt
,
nil
return
receipt
,
nil
}
}
func
checkNodeGroupAddrsMatch
(
applyAddr
,
confAddr
string
)
([]
string
,
error
)
{
func
(
a
*
action
)
nodeGroupApproveModify
(
config
*
pt
.
ParaNodeGroupConfig
,
modify
*
pt
.
ParaNodeGroupStatus
)
(
*
types
.
Receipt
,
error
)
{
confAddrs
:=
getAddrGroup
(
confAddr
)
stat
,
err
:=
getNodeGroupStatus
(
a
.
db
,
config
.
Title
)
applyAddrs
:=
strings
.
Split
(
applyAddr
,
","
)
if
err
!=
nil
{
return
nil
,
err
applys
:=
make
(
map
[
string
]
bool
)
configs
:=
make
(
map
[
string
]
bool
)
diff
:=
[]
string
{}
for
_
,
addr
:=
range
applyAddrs
{
applys
[
addr
]
=
true
}
for
_
,
addr
:=
range
confAddrs
{
configs
[
addr
]
=
true
}
}
if
len
(
applys
)
!=
len
(
configs
)
{
clog
.
Error
(
"node group addrs count not match"
,
"apply"
,
applyAddr
,
"quit"
,
confAddr
)
//approve modify case
return
nil
,
pt
.
ErrParaNodeGroupAddrNotMatch
if
modify
.
CoinsFrozen
<
config
.
CoinsFrozen
{
clog
.
Error
(
"nodeGroupApprove id not enough coins"
,
"id.coins"
,
modify
.
CoinsFrozen
,
"config.coins"
,
config
.
CoinsFrozen
)
return
nil
,
pt
.
ErrParaNodeGroupFrozenCoinsNotEnough
}
}
for
_
,
addr
:=
range
confAddrs
{
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
}
if
!
applys
[
addr
]
{
copyModify
:=
*
modify
diff
=
append
(
diff
,
addr
)
modify
.
Status
=
pt
.
ParacrossNodeGroupApprove
}
r
:=
makeNodeGroupApplyReceipt
(
a
.
fromaddr
,
&
copyModify
,
modify
,
pt
.
TyLogParaNodeGroupApprove
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
copyStat
:=
*
stat
//对已经approved group和addrs不再统一修改active&frozen改动的coins,因为可能有些addr已经退出group了,没退出的,退出时候按最初设置解冻
// 这里只修改参数,对后面再加入的节点起作用
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
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
return
receipt
,
nil
}
func
(
a
*
action
)
nodeGroupApproveApply
(
config
*
pt
.
ParaNodeGroupConfig
,
apply
*
pt
.
ParaNodeGroupStatus
)
(
*
types
.
Receipt
,
error
)
{
err
:=
a
.
checkNodeGroupExist
(
config
.
Title
)
if
err
!=
nil
{
return
nil
,
err
}
}
if
len
(
diff
)
>
0
{
clog
.
Error
(
"node group addrs not match"
,
"apply"
,
applyAddr
,
"quit"
,
confAddr
)
if
apply
.
CoinsFrozen
<
config
.
CoinsFrozen
{
return
nil
,
pt
.
ErrParaNodeGroupAddrNotMatch
clog
.
Error
(
"nodeGroupApprove id not enough coins"
,
"id.coins"
,
apply
.
CoinsFrozen
,
"config.coins"
,
config
.
CoinsFrozen
)
return
nil
,
pt
.
ErrParaNodeGroupFrozenCoinsNotEnough
}
}
return
confAddrs
,
nil
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
}
//create the node group
r
:=
a
.
nodeGroupCreate
(
apply
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
copyStat
:=
*
apply
apply
.
Status
=
pt
.
ParacrossNodeGroupApprove
apply
.
MainHeight
=
a
.
exec
.
GetMainHeight
()
r
=
makeNodeGroupApplyReceipt
(
a
.
fromaddr
,
&
copyStat
,
apply
,
pt
.
TyLogParaNodeGroupApprove
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
r
=
makeParaNodeGroupStatusReceipt
(
a
.
fromaddr
,
nil
,
apply
,
pt
.
TyLogParaNodeGroupStatusUpdate
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
return
receipt
,
nil
}
}
...
@@ -739,80 +816,58 @@ func (a *action) nodeGroupApprove(config *pt.ParaNodeGroupConfig) (*types.Receip
...
@@ -739,80 +816,58 @@ func (a *action) nodeGroupApprove(config *pt.ParaNodeGroupConfig) (*types.Receip
return
nil
,
types
.
ErrNotAllow
return
nil
,
types
.
ErrNotAllow
}
}
status
,
err
:=
getNodeGroupStatus
(
a
.
db
,
config
.
Title
)
IdStatus
,
err
:=
getNodeGroupId
(
a
.
db
,
config
.
Id
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
status
.
Status
!=
pt
.
ParacrossNodeGroupApply
{
clog
.
Error
(
"node group approve not apply status"
,
"status"
,
status
.
Status
)
return
nil
,
pt
.
ErrParaNodeGroupStatusWrong
}
if
status
.
CoinsFrozen
<
config
.
CoinsFrozen
{
if
config
.
Title
!=
IdStatus
.
Title
{
clog
.
Error
(
"node group approve not apply status"
,
"status"
,
status
.
Status
)
return
nil
,
errors
.
Wrapf
(
pt
.
ErrNodeNotForTheTitle
,
"config title:%s,id title:%s"
,
config
.
Title
,
IdStatus
.
Title
)
return
nil
,
pt
.
ErrParaNodeGroupFrozenCoinsNotEnough
}
}
applyAddrs
,
err
:=
checkNodeGroupAddrsMatch
(
status
.
ApplyAddr
,
config
.
Addrs
)
if
err
!=
nil
{
if
IdStatus
.
Status
==
pt
.
ParacrossNodeGroupModify
{
return
nil
,
err
return
a
.
nodeGroupApproveModify
(
config
,
IdStatus
)
}
}
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
}
if
IdStatus
.
Status
==
pt
.
ParacrossNodeGroupApply
{
//create the node group
return
a
.
nodeGroupApproveApply
(
config
,
IdStatus
)
r
,
err
:=
a
.
nodeGroupCreate
(
config
.
Title
,
applyAddrs
,
status
.
CoinsFrozen
,
status
.
FromAddr
)
if
err
!=
nil
{
return
nil
,
err
}
}
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
stat
:=
&
pt
.
ParaNodeGroupStatus
{
Status
:
pt
.
ParacrossNodeGroupApprove
,
clog
.
Error
(
"nodeGroupApprove id wrong status"
,
"status"
,
IdStatus
.
Status
,
"id"
,
config
.
Id
)
Title
:
config
.
Title
,
return
nil
,
pt
.
ErrParaNodeGroupStatusWrong
ApplyAddr
:
status
.
ApplyAddr
,
CoinsFrozen
:
status
.
CoinsFrozen
,
MainHeight
:
a
.
exec
.
GetMainHeight
(),
EmptyBlockInterval
:
status
.
EmptyBlockInterval
,
FromAddr
:
status
.
FromAddr
}
saveNodeGroup
(
a
.
db
,
config
.
Title
,
stat
)
r
=
makeParaNodeGroupApplyReiceipt
(
config
.
Title
,
a
.
fromaddr
,
status
,
stat
,
pt
.
TyLogParaNodeGroupApprove
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
return
receipt
,
nil
}
}
func
(
a
*
action
)
nodeGroupCreate
(
title
string
,
nodes
[]
string
,
coinFrozen
int64
,
createAddr
string
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
nodeGroupCreate
(
status
*
pt
.
ParaNodeGroupStatus
)
*
types
.
Receipt
{
nodes
:=
strings
.
Split
(
status
.
ApplyAddrs
,
","
)
var
item
types
.
ConfigItem
var
item
types
.
ConfigItem
key
:=
calcParaNodeGroupKey
(
title
)
key
:=
calcParaNodeGroup
Addrs
Key
(
title
)
item
.
Key
=
string
(
key
)
item
.
Key
=
string
(
key
)
emptyValue
:=
&
types
.
ArrayConfig
{
Value
:
make
([]
string
,
0
)}
emptyValue
:=
&
types
.
ArrayConfig
{
Value
:
make
([]
string
,
0
)}
arr
:=
types
.
ConfigItem_Arr
{
Arr
:
emptyValue
}
arr
:=
types
.
ConfigItem_Arr
{
Arr
:
emptyValue
}
item
.
Value
=
&
arr
item
.
Value
=
&
arr
item
.
GetArr
()
.
Value
=
append
(
item
.
GetArr
()
.
Value
,
nodes
...
)
item
.
GetArr
()
.
Value
=
append
(
item
.
GetArr
()
.
Value
,
nodes
...
)
item
.
Addr
=
a
.
fromaddr
item
.
Addr
=
a
.
fromaddr
a
.
db
.
Set
(
key
,
types
.
Encode
(
&
item
))
receipt
:=
makeParaNodeGroupRe
i
ceipt
(
title
,
nil
,
&
item
)
receipt
:=
makeParaNodeGroupReceipt
(
title
,
nil
,
&
item
)
//update addr status
//update addr status
for
_
,
addr
:=
range
nodes
{
for
i
,
addr
:=
range
nodes
{
stat
:=
&
pt
.
ParaNodeAddrStatus
{
Status
:
pt
.
ParacrossNodeAdded
,
stat
:=
&
pt
.
ParaNodeAddrStatus
{
Title
:
title
,
Id
:
status
.
Id
+
"-"
+
strconv
.
Itoa
(
i
),
Status
:
pt
.
ParacrossNodeJoined
,
Title
:
status
.
Title
,
ApplyAddr
:
addr
,
ApplyAddr
:
addr
,
Votes
:
&
pt
.
ParaNodeVoteDetail
{},
Votes
:
&
pt
.
ParaNodeVoteDetail
{
Addrs
:
[]
string
{
a
.
fromaddr
},
Votes
:
[]
string
{
"yes"
}},
CoinsFrozen
:
coinFrozen
,
CoinsFrozen
:
status
.
CoinsFrozen
,
FromAddr
:
createAddr
}
FromAddr
:
status
.
FromAddr
}
saveNodeAddr
(
a
.
db
,
title
,
addr
,
stat
)
config
:=
&
pt
.
ParaNodeAddrConfig
{
r
:=
makeNodeConfigReceipt
(
a
.
fromaddr
,
nil
,
nil
,
stat
)
Title
:
title
,
Addr
:
addr
,
CoinsFrozen
:
coinFrozen
,
}
r
:=
makeNodeConfigReceipt
(
a
.
fromaddr
,
config
,
nil
,
stat
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
}
}
return
receipt
,
nil
return
receipt
}
}
//NodeGroupConfig support super node group config
//NodeGroupConfig support super node group config
...
@@ -821,12 +876,11 @@ func (a *action) NodeGroupConfig(config *pt.ParaNodeGroupConfig) (*types.Receipt
...
@@ -821,12 +876,11 @@ func (a *action) NodeGroupConfig(config *pt.ParaNodeGroupConfig) (*types.Receipt
return
nil
,
pt
.
ErrInvalidTitle
return
nil
,
pt
.
ErrInvalidTitle
}
}
s
:=
strings
.
Trim
(
config
.
Addrs
,
" "
)
if
len
(
s
)
==
0
{
return
nil
,
types
.
ErrInvalidParam
}
if
config
.
Op
==
pt
.
ParacrossNodeGroupApply
{
if
config
.
Op
==
pt
.
ParacrossNodeGroupApply
{
s
:=
strings
.
Trim
(
config
.
Addrs
,
" "
)
if
len
(
s
)
==
0
{
return
nil
,
types
.
ErrInvalidParam
}
err
:=
a
.
checkNodeGroupExist
(
config
.
Title
)
err
:=
a
.
checkNodeGroupExist
(
config
.
Title
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -834,14 +888,19 @@ func (a *action) NodeGroupConfig(config *pt.ParaNodeGroupConfig) (*types.Receipt
...
@@ -834,14 +888,19 @@ func (a *action) NodeGroupConfig(config *pt.ParaNodeGroupConfig) (*types.Receipt
return
a
.
nodeGroupApply
(
config
)
return
a
.
nodeGroupApply
(
config
)
}
else
if
config
.
Op
==
pt
.
ParacrossNodeGroupApprove
{
}
else
if
config
.
Op
==
pt
.
ParacrossNodeGroupApprove
{
err
:=
a
.
checkNodeGroupExist
(
config
.
Title
)
if
config
.
Id
==
""
{
if
err
!=
nil
{
return
nil
,
types
.
ErrInvalidParam
return
nil
,
err
}
}
return
a
.
nodeGroupApprove
(
config
)
return
a
.
nodeGroupApprove
(
config
)
}
else
if
config
.
Op
==
pt
.
ParacrossNodeGroupQuit
{
}
else
if
config
.
Op
==
pt
.
ParacrossNodeGroupQuit
{
if
config
.
Id
==
""
{
return
nil
,
types
.
ErrInvalidParam
}
return
a
.
nodeGroupQuit
(
config
)
return
a
.
nodeGroupQuit
(
config
)
}
else
if
config
.
Op
==
pt
.
ParacrossNodeGroupModify
{
return
a
.
nodeGroupModify
(
config
)
}
}
return
nil
,
pt
.
ErrParaUnSupportNodeOper
return
nil
,
pt
.
ErrParaUnSupportNodeOper
...
@@ -858,9 +917,15 @@ func (a *action) NodeConfig(config *pt.ParaNodeAddrConfig) (*types.Receipt, erro
...
@@ -858,9 +917,15 @@ func (a *action) NodeConfig(config *pt.ParaNodeAddrConfig) (*types.Receipt, erro
return
a
.
nodeJoin
(
config
)
return
a
.
nodeJoin
(
config
)
}
else
if
config
.
Op
==
pt
.
ParaNodeQuit
{
}
else
if
config
.
Op
==
pt
.
ParaNodeQuit
{
if
config
.
Id
==
""
{
return
nil
,
types
.
ErrInvalidParam
}
return
a
.
nodeQuit
(
config
)
return
a
.
nodeQuit
(
config
)
}
else
if
config
.
Op
==
pt
.
ParaNodeVote
{
}
else
if
config
.
Op
==
pt
.
ParaNodeVote
{
if
config
.
Id
==
""
{
return
nil
,
types
.
ErrInvalidParam
}
return
a
.
nodeVote
(
config
)
return
a
.
nodeVote
(
config
)
}
}
...
...
plugin/dapp/paracross/executor/superaccount_test.go
View file @
f11abc5b
...
@@ -74,7 +74,7 @@ func (suite *NodeManageTestSuite) SetupSuite() {
...
@@ -74,7 +74,7 @@ func (suite *NodeManageTestSuite) SetupSuite() {
}
}
func
(
suite
*
NodeManageTestSuite
)
TestSetup
()
{
func
(
suite
*
NodeManageTestSuite
)
TestSetup
()
{
nodeConfigKey
:=
calcParaNodeGroupKey
(
Title
)
nodeConfigKey
:=
calcParaNodeGroup
Addrs
Key
(
Title
)
suite
.
T
()
.
Log
(
string
(
nodeConfigKey
))
suite
.
T
()
.
Log
(
string
(
nodeConfigKey
))
_
,
err
:=
suite
.
stateDB
.
Get
(
nodeConfigKey
)
_
,
err
:=
suite
.
stateDB
.
Get
(
nodeConfigKey
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -139,7 +139,7 @@ func checkJoinReceipt(suite *NodeManageTestSuite, receipt *types.Receipt) {
...
@@ -139,7 +139,7 @@ func checkJoinReceipt(suite *NodeManageTestSuite, receipt *types.Receipt) {
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
.
TyLogParaNodeConfig
),
receipt
.
Logs
[
0
]
.
Ty
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
TyLogParaNodeConfig
),
receipt
.
Logs
[
0
]
.
Ty
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
ParacrossNode
Add
ing
),
stat
.
Status
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
ParacrossNode
Join
ing
),
stat
.
Status
)
assert
.
NotNil
(
suite
.
T
(),
stat
.
Votes
)
assert
.
NotNil
(
suite
.
T
(),
stat
.
Votes
)
}
}
...
@@ -310,22 +310,22 @@ func (suite *NodeManageTestSuite) TearDownSuite() {
...
@@ -310,22 +310,22 @@ func (suite *NodeManageTestSuite) TearDownSuite() {
func
TestGetAddrGroup
(
t
*
testing
.
T
)
{
func
TestGetAddrGroup
(
t
*
testing
.
T
)
{
addrs
:=
" 1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4, 1JRNjdEqp4LJ5fqycUBm9ayCKSeeskgMKR, 1NLHPEcbTWWxxU3dGUZBhayjrCHD3psX7k, ,,, 1MCftFynyvG2F4ED5mdHYgziDxx6vDrScs , "
addrs
:=
" 1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4, 1JRNjdEqp4LJ5fqycUBm9ayCKSeeskgMKR, 1NLHPEcbTWWxxU3dGUZBhayjrCHD3psX7k, ,,, 1MCftFynyvG2F4ED5mdHYgziDxx6vDrScs , "
retAddrs
:=
get
AddrGroup
(
addrs
)
retAddrs
:=
get
ConfigAddrs
(
addrs
)
expectAddrs
:=
[]
string
{
"1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4"
,
"1JRNjdEqp4LJ5fqycUBm9ayCKSeeskgMKR"
,
"1NLHPEcbTWWxxU3dGUZBhayjrCHD3psX7k"
,
"1MCftFynyvG2F4ED5mdHYgziDxx6vDrScs"
}
expectAddrs
:=
[]
string
{
"1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4"
,
"1JRNjdEqp4LJ5fqycUBm9ayCKSeeskgMKR"
,
"1NLHPEcbTWWxxU3dGUZBhayjrCHD3psX7k"
,
"1MCftFynyvG2F4ED5mdHYgziDxx6vDrScs"
}
assert
.
Equal
(
t
,
expectAddrs
,
retAddrs
)
assert
.
Equal
(
t
,
expectAddrs
,
retAddrs
)
addrs
=
" 1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4 , , "
addrs
=
" 1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4 , , "
retAddrs
=
get
AddrGroup
(
addrs
)
retAddrs
=
get
ConfigAddrs
(
addrs
)
expectAddrs
=
[]
string
{
"1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4"
}
expectAddrs
=
[]
string
{
"1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4"
}
assert
.
Equal
(
t
,
expectAddrs
,
retAddrs
)
assert
.
Equal
(
t
,
expectAddrs
,
retAddrs
)
addrs
=
" , "
addrs
=
" , "
ret
:=
get
AddrGroup
(
addrs
)
ret
:=
get
ConfigAddrs
(
addrs
)
assert
.
Equal
(
t
,
[]
string
(
nil
),
ret
)
assert
.
Equal
(
t
,
[]
string
(
nil
),
ret
)
assert
.
Equal
(
t
,
0
,
len
(
ret
))
assert
.
Equal
(
t
,
0
,
len
(
ret
))
addrs
=
" "
addrs
=
" "
ret
=
get
AddrGroup
(
addrs
)
ret
=
get
ConfigAddrs
(
addrs
)
assert
.
Equal
(
t
,
[]
string
(
nil
),
ret
)
assert
.
Equal
(
t
,
[]
string
(
nil
),
ret
)
assert
.
Equal
(
t
,
0
,
len
(
ret
))
assert
.
Equal
(
t
,
0
,
len
(
ret
))
...
...
plugin/dapp/paracross/proto/paracross.proto
View file @
f11abc5b
...
@@ -50,9 +50,10 @@ message ParacrossConsensusStatus {
...
@@ -50,9 +50,10 @@ message ParacrossConsensusStatus {
message
ParaNodeAddrConfig
{
message
ParaNodeAddrConfig
{
string
title
=
1
;
string
title
=
1
;
string
op
=
2
;
string
op
=
2
;
string
addr
=
3
;
string
id
=
3
;
string
value
=
4
;
string
addr
=
4
;
int64
coinsFrozen
=
5
;
string
value
=
5
;
int64
coinsFrozen
=
6
;
}
}
...
@@ -62,12 +63,13 @@ message ParaNodeVoteDetail{
...
@@ -62,12 +63,13 @@ message ParaNodeVoteDetail{
}
}
message
ParaNodeAddrStatus
{
message
ParaNodeAddrStatus
{
int32
status
=
1
;
string
id
=
1
;
string
title
=
2
;
int32
status
=
2
;
string
applyAddr
=
3
;
string
title
=
3
;
int64
coinsFrozen
=
4
;
string
applyAddr
=
4
;
ParaNodeVoteDetail
votes
=
5
;
int64
coinsFrozen
=
5
;
string
fromAddr
=
6
;
ParaNodeVoteDetail
votes
=
6
;
string
fromAddr
=
7
;
}
}
...
@@ -78,40 +80,38 @@ message ReceiptParaNodeConfig {
...
@@ -78,40 +80,38 @@ message ReceiptParaNodeConfig {
ParaNodeAddrStatus
current
=
4
;
ParaNodeAddrStatus
current
=
4
;
}
}
message
ReceiptParaNodeVoteRecord
{
string
fromAddr
=
1
;
string
voteAddr
=
2
;
int32
value
=
3
;
}
message
ReceiptParaNodeVoteDone
{
message
ReceiptParaNodeVoteDone
{
string
title
=
1
;
string
id
=
1
;
string
targetAddr
=
2
;
string
title
=
2
;
int32
totalNodes
=
3
;
string
targetAddr
=
3
;
int32
totalVote
=
4
;
int32
totalNodes
=
4
;
int32
mostVote
=
5
;
int32
totalVote
=
5
;
string
voteRst
=
6
;
int32
mostVote
=
6
;
int32
doneStatus
=
7
;
string
voteRst
=
7
;
int32
doneStatus
=
8
;
}
}
message
ParaNodeGroupConfig
{
message
ParaNodeGroupConfig
{
string
title
=
1
;
string
title
=
1
;
uint32
op
=
2
;
uint32
op
=
2
;
string
addrs
=
3
;
string
id
=
3
;
int64
coinsFrozen
=
4
;
string
addrs
=
4
;
uint32
emptyBlockInterval
=
5
;
int64
coinsFrozen
=
5
;
uint32
emptyBlockInterval
=
6
;
}
}
message
ParaNodeGroupStatus
{
message
ParaNodeGroupStatus
{
int32
status
=
1
;
string
id
=
1
;
string
title
=
2
;
int32
status
=
2
;
string
applyAddr
=
3
;
string
title
=
3
;
int64
coinsFrozen
=
4
;
string
applyAddrs
=
4
;
uint32
emptyBlockInterval
=
5
;
int64
coinsFrozen
=
5
;
int64
mainHeight
=
6
;
uint32
emptyBlockInterval
=
6
;
string
fromAddr
=
7
;
int64
mainHeight
=
7
;
string
fromAddr
=
8
;
}
}
message
ReceiptParaNodeGroupConfig
{
message
ReceiptParaNodeGroupConfig
{
...
...
plugin/dapp/paracross/types/errors.go
View file @
f11abc5b
...
@@ -47,8 +47,6 @@ var (
...
@@ -47,8 +47,6 @@ var (
ErrParaNodeGroupFrozenCoinsNotEnough
=
errors
.
New
(
"ErrParaNodeGroupFrozenCoinsNotEnough"
)
ErrParaNodeGroupFrozenCoinsNotEnough
=
errors
.
New
(
"ErrParaNodeGroupFrozenCoinsNotEnough"
)
//ErrParaNodeGroupStatusWrong node group process wrong status
//ErrParaNodeGroupStatusWrong node group process wrong status
ErrParaNodeGroupStatusWrong
=
errors
.
New
(
"ErrParaNodeGroupStatusWrong"
)
ErrParaNodeGroupStatusWrong
=
errors
.
New
(
"ErrParaNodeGroupStatusWrong"
)
//ErrParaNodeGroupAddrNotMatch group addrs not match with apply
ErrParaNodeGroupAddrNotMatch
=
errors
.
New
(
"ErrParaNodeGroupAddrNotMatch"
)
//ErrParaConsensStopBlocksNotReach consensus stop blocks not reach
//ErrParaConsensStopBlocksNotReach consensus stop blocks not reach
ErrParaConsensStopBlocksNotReach
=
errors
.
New
(
"ErrParaConsensStopBlocksNotReach"
)
ErrParaConsensStopBlocksNotReach
=
errors
.
New
(
"ErrParaConsensStopBlocksNotReach"
)
)
)
plugin/dapp/paracross/types/paracross.go
View file @
f11abc5b
...
@@ -37,12 +37,14 @@ const (
...
@@ -37,12 +37,14 @@ const (
// TyLogParaAssetDeposit asset deposit log key
// TyLogParaAssetDeposit asset deposit log key
TyLogParaAssetDeposit
=
656
TyLogParaAssetDeposit
=
656
// TyLogParaNodeConfig config super node log key
// TyLogParaNodeConfig config super node log key
TyLogParaNodeConfig
=
657
TyLogParaNodeConfig
=
657
TyLogParaNodeVoteDone
=
658
TyLogParaNodeVoteDone
=
658
TyLogParaNodeGroupUpdate
=
659
TyLogParaNodeGroupAddrsUpdate
=
659
TyLogParaNodeGroupApply
=
660
TyLogParaNodeGroupApply
=
660
TyLogParaNodeGroupApprove
=
661
TyLogParaNodeGroupApprove
=
661
TyLogParaNodeGroupQuit
=
662
TyLogParaNodeGroupQuit
=
662
TyLogParaNodeGroupModify
=
663
TyLogParaNodeGroupStatusUpdate
=
664
)
)
type
paracrossCommitTx
struct
{
type
paracrossCommitTx
struct
{
...
@@ -99,10 +101,10 @@ const (
...
@@ -99,10 +101,10 @@ const (
)
)
const
(
const
(
// ParacrossNode
Add
ing apply for adding group
// ParacrossNode
Join
ing apply for adding group
ParacrossNode
Add
ing
=
iota
+
1
ParacrossNode
Join
ing
=
iota
+
1
// ParacrossNode
Add
ed pass to add by votes
// ParacrossNode
Join
ed pass to add by votes
ParacrossNode
Add
ed
ParacrossNode
Join
ed
// ParacrossNodeQuiting apply for quiting
// ParacrossNodeQuiting apply for quiting
ParacrossNodeQuiting
ParacrossNodeQuiting
// ParacrossNodeQuited pass to quite by votes
// ParacrossNodeQuited pass to quite by votes
...
@@ -116,6 +118,8 @@ const (
...
@@ -116,6 +118,8 @@ const (
ParacrossNodeGroupApprove
ParacrossNodeGroupApprove
//ParacrossNodeGroupQuit applyer quit the apply when not be approved
//ParacrossNodeGroupQuit applyer quit the apply when not be approved
ParacrossNodeGroupQuit
ParacrossNodeGroupQuit
//ParacrossNodeGroupModify applyer modify some parameters
ParacrossNodeGroupModify
)
)
var
(
var
(
...
...
plugin/dapp/paracross/types/type.go
View file @
f11abc5b
...
@@ -54,19 +54,21 @@ func (p *ParacrossType) GetName() string {
...
@@ -54,19 +54,21 @@ func (p *ParacrossType) GetName() string {
// GetLogMap get receipt log map
// GetLogMap get receipt log map
func
(
p
*
ParacrossType
)
GetLogMap
()
map
[
int64
]
*
types
.
LogInfo
{
func
(
p
*
ParacrossType
)
GetLogMap
()
map
[
int64
]
*
types
.
LogInfo
{
return
map
[
int64
]
*
types
.
LogInfo
{
return
map
[
int64
]
*
types
.
LogInfo
{
TyLogParacrossCommit
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParacrossCommit
{}),
Name
:
"LogParacrossCommit"
},
TyLogParacrossCommit
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParacrossCommit
{}),
Name
:
"LogParacrossCommit"
},
TyLogParacrossCommitDone
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParacrossDone
{}),
Name
:
"LogParacrossCommitDone"
},
TyLogParacrossCommitDone
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParacrossDone
{}),
Name
:
"LogParacrossCommitDone"
},
TyLogParacrossCommitRecord
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParacrossRecord
{}),
Name
:
"LogParacrossCommitRecord"
},
TyLogParacrossCommitRecord
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParacrossRecord
{}),
Name
:
"LogParacrossCommitRecord"
},
TyLogParaAssetWithdraw
:
{
Ty
:
reflect
.
TypeOf
(
types
.
ReceiptAccountTransfer
{}),
Name
:
"LogParaAssetWithdraw"
},
TyLogParaAssetWithdraw
:
{
Ty
:
reflect
.
TypeOf
(
types
.
ReceiptAccountTransfer
{}),
Name
:
"LogParaAssetWithdraw"
},
TyLogParaAssetTransfer
:
{
Ty
:
reflect
.
TypeOf
(
types
.
ReceiptAccountTransfer
{}),
Name
:
"LogParaAssetTransfer"
},
TyLogParaAssetTransfer
:
{
Ty
:
reflect
.
TypeOf
(
types
.
ReceiptAccountTransfer
{}),
Name
:
"LogParaAssetTransfer"
},
TyLogParaAssetDeposit
:
{
Ty
:
reflect
.
TypeOf
(
types
.
ReceiptAccountTransfer
{}),
Name
:
"LogParaAssetDeposit"
},
TyLogParaAssetDeposit
:
{
Ty
:
reflect
.
TypeOf
(
types
.
ReceiptAccountTransfer
{}),
Name
:
"LogParaAssetDeposit"
},
TyLogParacrossMiner
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParacrossMiner
{}),
Name
:
"LogParacrossMiner"
},
TyLogParacrossMiner
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParacrossMiner
{}),
Name
:
"LogParacrossMiner"
},
TyLogParaNodeConfig
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeConfig
{}),
Name
:
"LogParaNodeConfig"
},
TyLogParaNodeConfig
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeConfig
{}),
Name
:
"LogParaNodeConfig"
},
TyLogParaNodeGroupUpdate
:
{
Ty
:
reflect
.
TypeOf
(
types
.
ReceiptConfig
{}),
Name
:
"LogParaNodeGroupUpdate"
},
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"
},
TyLogParaNodeGroupApply
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeGroupConfig
{}),
Name
:
"LogParaNodeGroupApply"
},
TyLogParaNodeGroupApprove
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeGroupConfig
{}),
Name
:
"LogParaNodeGroupApprove"
},
TyLogParaNodeGroupApprove
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeGroupConfig
{}),
Name
:
"LogParaNodeGroupApprove"
},
TyLogParaNodeGroupQuit
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeGroupConfig
{}),
Name
:
"LogParaNodeGroupQuit"
},
TyLogParaNodeGroupQuit
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeGroupConfig
{}),
Name
:
"LogParaNodeGroupQuit"
},
TyLogParaNodeGroupModify
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeGroupConfig
{}),
Name
:
"LogParaNodeGroupModify"
},
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