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
513b605d
Commit
513b605d
authored
May 24, 2019
by
mdj33
Committed by
vipwzw
May 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
node group support behalf create
parent
4c3409fb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
41 deletions
+36
-41
superaccount.go
plugin/dapp/paracross/executor/superaccount.go
+35
-41
paracross.proto
plugin/dapp/paracross/proto/paracross.proto
+1
-0
No files found.
plugin/dapp/paracross/executor/superaccount.go
View file @
513b605d
...
@@ -165,7 +165,7 @@ func (a *action) nodeJoin(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
...
@@ -165,7 +165,7 @@ func (a *action) nodeJoin(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
}
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
}
if
!
types
.
IsPara
()
{
if
!
types
.
IsPara
()
{
r
,
err
:=
a
.
nodeGroupCoinsFrozen
(
[]
string
{
a
.
fromaddr
},
config
.
CoinsFrozen
)
r
,
err
:=
a
.
nodeGroupCoinsFrozen
(
a
.
fromaddr
,
config
.
CoinsFrozen
,
1
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -258,7 +258,7 @@ func (a *action) nodeQuit(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
...
@@ -258,7 +258,7 @@ func (a *action) nodeQuit(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
//still adding status, quit directly
//still adding status, quit directly
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
}
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
}
if
!
types
.
IsPara
()
{
if
!
types
.
IsPara
()
{
r
,
err
:=
a
.
nodeGroupCoinsActive
(
[]
string
{
stat
.
FromAddr
},
stat
.
CoinsFrozen
)
r
,
err
:=
a
.
nodeGroupCoinsActive
(
stat
.
FromAddr
,
stat
.
CoinsFrozen
,
1
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -438,7 +438,7 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
...
@@ -438,7 +438,7 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
stat
.
Status
=
pt
.
ParacrossNodeQuited
stat
.
Status
=
pt
.
ParacrossNodeQuited
if
!
types
.
IsPara
()
{
if
!
types
.
IsPara
()
{
r
,
err
:=
a
.
nodeGroupCoinsActive
(
[]
string
{
stat
.
FromAddr
},
stat
.
CoinsFrozen
)
r
,
err
:=
a
.
nodeGroupCoinsActive
(
stat
.
FromAddr
,
stat
.
CoinsFrozen
,
1
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -546,40 +546,35 @@ func (a *action) checkNodeGroupExist(title string) error {
...
@@ -546,40 +546,35 @@ func (a *action) checkNodeGroupExist(title string) error {
return
nil
return
nil
}
}
func
(
a
*
action
)
nodeGroupCoinsFrozen
(
addrs
[]
string
,
configCoinsFrozen
int64
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
nodeGroupCoinsFrozen
(
createAddr
string
,
configCoinsFrozen
int64
,
nodeCounts
int64
)
(
*
types
.
Receipt
,
error
)
{
receipt
:=
&
types
.
Receipt
{}
receipt
:=
&
types
.
Receipt
{}
confCoins
:=
conf
.
GInt
(
"nodeGroupFrozenCoins"
)
confCoins
:=
conf
.
GInt
(
"nodeGroupFrozenCoins"
)
if
configCoinsFrozen
<
confCoins
{
if
configCoinsFrozen
<
confCoins
{
return
nil
,
pt
.
ErrParaNodeGroupFrozenCoinsNotEnough
return
nil
,
pt
.
ErrParaNodeGroupFrozenCoinsNotEnough
}
}
if
configCoinsFrozen
==
0
{
if
configCoinsFrozen
==
0
{
clog
.
Info
(
"node group apply configCoinsFrozen is 0"
)
return
receipt
,
nil
return
receipt
,
nil
}
}
var
logs
[]
*
types
.
ReceiptLog
var
kv
[]
*
types
.
KeyValue
realExec
:=
string
(
types
.
GetRealExecName
(
a
.
tx
.
Execer
))
realExec
:=
string
(
types
.
GetRealExecName
(
a
.
tx
.
Execer
))
realExecAddr
:=
dapp
.
ExecAddress
(
realExec
)
realExecAddr
:=
dapp
.
ExecAddress
(
realExec
)
for
_
,
addr
:=
range
addrs
{
r
,
err
:=
a
.
coinsAccount
.
ExecFrozen
(
createAddr
,
realExecAddr
,
nodeCounts
*
configCoinsFrozen
)
r
,
err
:=
a
.
coinsAccount
.
ExecFrozen
(
addr
,
realExecAddr
,
configCoinsFrozen
)
if
err
!=
nil
{
if
err
!=
nil
{
clog
.
Error
(
"node group apply"
,
"addr"
,
a
ddr
,
"realExec"
,
realExec
,
"realAddr"
,
realExecAddr
,
"amount"
,
configCoinsFrozen
)
clog
.
Error
(
"node group apply"
,
"addr"
,
createA
ddr
,
"realExec"
,
realExec
,
"realAddr"
,
realExecAddr
,
"amount"
,
configCoinsFrozen
)
return
nil
,
err
return
nil
,
err
}
}
logs
=
append
(
logs
,
r
.
Logs
...
)
kv
=
append
(
kv
,
r
.
KV
...
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
}
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
receipt
.
KV
=
append
(
receipt
.
KV
,
kv
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
logs
...
)
return
receipt
,
nil
return
receipt
,
nil
}
}
func
(
a
*
action
)
nodeGroupCoinsActive
(
addrs
[]
string
,
configCoinsFrozen
int64
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
nodeGroupCoinsActive
(
createAddr
string
,
configCoinsFrozen
int64
,
nodeCount
int64
)
(
*
types
.
Receipt
,
error
)
{
receipt
:=
&
types
.
Receipt
{}
receipt
:=
&
types
.
Receipt
{}
var
logs
[]
*
types
.
ReceiptLog
var
kv
[]
*
types
.
KeyValue
realExec
:=
string
(
types
.
GetRealExecName
(
a
.
tx
.
Execer
))
realExec
:=
string
(
types
.
GetRealExecName
(
a
.
tx
.
Execer
))
realExecAddr
:=
dapp
.
ExecAddress
(
realExec
)
realExecAddr
:=
dapp
.
ExecAddress
(
realExec
)
...
@@ -587,17 +582,15 @@ func (a *action) nodeGroupCoinsActive(addrs []string, configCoinsFrozen int64) (
...
@@ -587,17 +582,15 @@ func (a *action) nodeGroupCoinsActive(addrs []string, configCoinsFrozen int64) (
return
receipt
,
nil
return
receipt
,
nil
}
}
for
_
,
addr
:=
range
addrs
{
r
,
err
:=
a
.
coinsAccount
.
ExecActive
(
createAddr
,
realExecAddr
,
nodeCount
*
configCoinsFrozen
)
r
,
err
:=
a
.
coinsAccount
.
ExecActive
(
addr
,
realExecAddr
,
configCoinsFrozen
)
if
err
!=
nil
{
if
err
!=
nil
{
clog
.
Error
(
"node group apply"
,
"addr"
,
addr
,
"realExec"
,
realExec
,
"realAddr"
,
realExecAddr
,
"amount"
,
configCoinsFrozen
)
clog
.
Error
(
"node group apply"
,
"addr"
,
createAddr
,
"realExec"
,
realExec
,
"realAddr"
,
realExecAddr
,
"amount"
,
configCoinsFrozen
,
"nodeCount"
,
nodeCount
)
return
nil
,
err
return
nil
,
err
}
}
logs
=
append
(
logs
,
r
.
Logs
...
)
kv
=
append
(
kv
,
r
.
KV
...
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
}
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
receipt
.
KV
=
append
(
receipt
.
KV
,
kv
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
logs
...
)
return
receipt
,
nil
return
receipt
,
nil
}
}
...
@@ -617,7 +610,7 @@ func (a *action) nodeGroupApply(config *pt.ParaNodeGroupConfig) (*types.Receipt,
...
@@ -617,7 +610,7 @@ func (a *action) nodeGroupApply(config *pt.ParaNodeGroupConfig) (*types.Receipt,
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
.
nodeGroupCoinsFrozen
(
a
ddrs
,
config
.
CoinsFrozen
)
r
,
err
:=
a
.
nodeGroupCoinsFrozen
(
a
.
fromaddr
,
config
.
CoinsFrozen
,
int64
(
len
(
addrs
))
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -631,7 +624,8 @@ func (a *action) nodeGroupApply(config *pt.ParaNodeGroupConfig) (*types.Receipt,
...
@@ -631,7 +624,8 @@ func (a *action) nodeGroupApply(config *pt.ParaNodeGroupConfig) (*types.Receipt,
ApplyAddr
:
strings
.
Join
(
addrs
,
","
),
ApplyAddr
:
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
}
saveNodeGroup
(
a
.
db
,
config
.
Title
,
stat
)
saveNodeGroup
(
a
.
db
,
config
.
Title
,
stat
)
r
:=
makeParaNodeGroupApplyReiceipt
(
config
.
Title
,
a
.
fromaddr
,
status
,
stat
,
pt
.
TyLogParaNodeGroupApply
)
r
:=
makeParaNodeGroupApplyReiceipt
(
config
.
Title
,
a
.
fromaddr
,
status
,
stat
,
pt
.
TyLogParaNodeGroupApply
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
...
@@ -650,6 +644,11 @@ func (a *action) nodeGroupQuit(config *pt.ParaNodeGroupConfig) (*types.Receipt,
...
@@ -650,6 +644,11 @@ func (a *action) nodeGroupQuit(config *pt.ParaNodeGroupConfig) (*types.Receipt,
return
nil
,
pt
.
ErrParaNodeGroupStatusWrong
return
nil
,
pt
.
ErrParaNodeGroupStatusWrong
}
}
if
status
.
FromAddr
!=
a
.
fromaddr
{
clog
.
Error
(
"node group create addr err"
,
"createAddr"
,
status
.
FromAddr
,
"currAddr"
,
a
.
fromaddr
)
return
nil
,
types
.
ErrNotAllow
}
applyAddrs
,
err
:=
checkNodeGroupAddrsMatch
(
status
.
ApplyAddr
,
config
.
Addrs
)
applyAddrs
,
err
:=
checkNodeGroupAddrsMatch
(
status
.
ApplyAddr
,
config
.
Addrs
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -658,7 +657,7 @@ func (a *action) nodeGroupQuit(config *pt.ParaNodeGroupConfig) (*types.Receipt,
...
@@ -658,7 +657,7 @@ func (a *action) nodeGroupQuit(config *pt.ParaNodeGroupConfig) (*types.Receipt,
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
pplyAddrs
,
status
.
CoinsFrozen
)
r
,
err
:=
a
.
nodeGroupCoinsActive
(
a
.
fromaddr
,
status
.
CoinsFrozen
,
int64
(
len
(
applyAddrs
))
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -671,7 +670,8 @@ func (a *action) nodeGroupQuit(config *pt.ParaNodeGroupConfig) (*types.Receipt,
...
@@ -671,7 +670,8 @@ func (a *action) nodeGroupQuit(config *pt.ParaNodeGroupConfig) (*types.Receipt,
ApplyAddr
:
status
.
ApplyAddr
,
ApplyAddr
:
status
.
ApplyAddr
,
CoinsFrozen
:
status
.
CoinsFrozen
,
CoinsFrozen
:
status
.
CoinsFrozen
,
MainHeight
:
a
.
exec
.
GetMainHeight
(),
MainHeight
:
a
.
exec
.
GetMainHeight
(),
EmptyBlockInterval
:
status
.
EmptyBlockInterval
}
EmptyBlockInterval
:
status
.
EmptyBlockInterval
,
FromAddr
:
a
.
fromaddr
}
saveNodeGroup
(
a
.
db
,
config
.
Title
,
stat
)
saveNodeGroup
(
a
.
db
,
config
.
Title
,
stat
)
r
:=
makeParaNodeGroupApplyReiceipt
(
config
.
Title
,
a
.
fromaddr
,
status
,
stat
,
pt
.
TyLogParaNodeGroupQuit
)
r
:=
makeParaNodeGroupApplyReiceipt
(
config
.
Title
,
a
.
fromaddr
,
status
,
stat
,
pt
.
TyLogParaNodeGroupQuit
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
...
@@ -734,7 +734,7 @@ func (a *action) nodeGroupApprove(config *pt.ParaNodeGroupConfig) (*types.Receip
...
@@ -734,7 +734,7 @@ func (a *action) nodeGroupApprove(config *pt.ParaNodeGroupConfig) (*types.Receip
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
}
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
}
//create the node group
//create the node group
r
,
err
:=
a
.
nodeGroupCreate
(
config
.
Title
,
applyAddrs
,
config
.
CoinsFrozen
)
r
,
err
:=
a
.
nodeGroupCreate
(
config
.
Title
,
applyAddrs
,
status
.
CoinsFrozen
,
status
.
FromAddr
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -746,7 +746,8 @@ func (a *action) nodeGroupApprove(config *pt.ParaNodeGroupConfig) (*types.Receip
...
@@ -746,7 +746,8 @@ func (a *action) nodeGroupApprove(config *pt.ParaNodeGroupConfig) (*types.Receip
ApplyAddr
:
status
.
ApplyAddr
,
ApplyAddr
:
status
.
ApplyAddr
,
CoinsFrozen
:
status
.
CoinsFrozen
,
CoinsFrozen
:
status
.
CoinsFrozen
,
MainHeight
:
a
.
exec
.
GetMainHeight
(),
MainHeight
:
a
.
exec
.
GetMainHeight
(),
EmptyBlockInterval
:
status
.
EmptyBlockInterval
}
EmptyBlockInterval
:
status
.
EmptyBlockInterval
,
FromAddr
:
status
.
FromAddr
}
saveNodeGroup
(
a
.
db
,
config
.
Title
,
stat
)
saveNodeGroup
(
a
.
db
,
config
.
Title
,
stat
)
r
=
makeParaNodeGroupApplyReiceipt
(
config
.
Title
,
a
.
fromaddr
,
status
,
stat
,
pt
.
TyLogParaNodeGroupApprove
)
r
=
makeParaNodeGroupApplyReiceipt
(
config
.
Title
,
a
.
fromaddr
,
status
,
stat
,
pt
.
TyLogParaNodeGroupApprove
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
...
@@ -755,7 +756,7 @@ func (a *action) nodeGroupApprove(config *pt.ParaNodeGroupConfig) (*types.Receip
...
@@ -755,7 +756,7 @@ func (a *action) nodeGroupApprove(config *pt.ParaNodeGroupConfig) (*types.Receip
return
receipt
,
nil
return
receipt
,
nil
}
}
func
(
a
*
action
)
nodeGroupCreate
(
title
string
,
nodes
[]
string
,
coinFrozen
int64
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
nodeGroupCreate
(
title
string
,
nodes
[]
string
,
coinFrozen
int64
,
createAddr
string
)
(
*
types
.
Receipt
,
error
)
{
var
item
types
.
ConfigItem
var
item
types
.
ConfigItem
key
:=
calcParaNodeGroupKey
(
title
)
key
:=
calcParaNodeGroupKey
(
title
)
item
.
Key
=
string
(
key
)
item
.
Key
=
string
(
key
)
...
@@ -774,7 +775,8 @@ func (a *action) nodeGroupCreate(title string, nodes []string, coinFrozen int64)
...
@@ -774,7 +775,8 @@ func (a *action) nodeGroupCreate(title string, nodes []string, coinFrozen int64)
Title
:
title
,
Title
:
title
,
ApplyAddr
:
addr
,
ApplyAddr
:
addr
,
Votes
:
&
pt
.
ParaNodeVoteDetail
{},
Votes
:
&
pt
.
ParaNodeVoteDetail
{},
CoinsFrozen
:
coinFrozen
}
CoinsFrozen
:
coinFrozen
,
FromAddr
:
createAddr
}
saveNodeAddr
(
a
.
db
,
title
,
addr
,
stat
)
saveNodeAddr
(
a
.
db
,
title
,
addr
,
stat
)
config
:=
&
pt
.
ParaNodeAddrConfig
{
config
:=
&
pt
.
ParaNodeAddrConfig
{
Title
:
title
,
Title
:
title
,
...
@@ -799,10 +801,6 @@ func (a *action) NodeGroupConfig(config *pt.ParaNodeGroupConfig) (*types.Receipt
...
@@ -799,10 +801,6 @@ func (a *action) NodeGroupConfig(config *pt.ParaNodeGroupConfig) (*types.Receipt
}
}
if
config
.
Op
==
pt
.
ParacrossNodeGroupApply
{
if
config
.
Op
==
pt
.
ParacrossNodeGroupApply
{
if
!
strings
.
Contains
(
config
.
Addrs
,
a
.
fromaddr
)
{
clog
.
Error
(
"node group apply fromaddr not one of apply addrs"
,
"addr"
,
a
.
fromaddr
,
"apply"
,
config
.
Addrs
)
return
nil
,
types
.
ErrNotAllow
}
err
:=
a
.
checkNodeGroupExist
(
config
.
Title
)
err
:=
a
.
checkNodeGroupExist
(
config
.
Title
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -817,10 +815,6 @@ func (a *action) NodeGroupConfig(config *pt.ParaNodeGroupConfig) (*types.Receipt
...
@@ -817,10 +815,6 @@ func (a *action) NodeGroupConfig(config *pt.ParaNodeGroupConfig) (*types.Receipt
return
a
.
nodeGroupApprove
(
config
)
return
a
.
nodeGroupApprove
(
config
)
}
else
if
config
.
Op
==
pt
.
ParacrossNodeGroupQuit
{
}
else
if
config
.
Op
==
pt
.
ParacrossNodeGroupQuit
{
if
!
strings
.
Contains
(
config
.
Addrs
,
a
.
fromaddr
)
{
clog
.
Error
(
"node group apply fromaddr not one of apply addrs"
,
"addr"
,
a
.
fromaddr
,
"apply"
,
config
.
Addrs
)
return
nil
,
types
.
ErrNotAllow
}
return
a
.
nodeGroupQuit
(
config
)
return
a
.
nodeGroupQuit
(
config
)
}
}
...
...
plugin/dapp/paracross/proto/paracross.proto
View file @
513b605d
...
@@ -99,6 +99,7 @@ message ParaNodeGroupStatus {
...
@@ -99,6 +99,7 @@ message ParaNodeGroupStatus {
int64
coinsFrozen
=
4
;
int64
coinsFrozen
=
4
;
uint32
emptyBlockInterval
=
5
;
uint32
emptyBlockInterval
=
5
;
int64
mainHeight
=
6
;
int64
mainHeight
=
6
;
string
fromAddr
=
7
;
}
}
message
ReceiptParaNodeGroupConfig
{
message
ReceiptParaNodeGroupConfig
{
...
...
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