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
28e5ae03
Commit
28e5ae03
authored
Sep 11, 2020
by
QM
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updata
parent
a87aae94
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
87 deletions
+84
-87
superaccount_test.go
plugin/dapp/paracross/executor/superaccount_test.go
+1
-0
supervisionaccount.go
plugin/dapp/paracross/executor/supervisionaccount.go
+82
-82
supervisionaccount_test.go
plugin/dapp/paracross/executor/supervisionaccount_test.go
+1
-5
No files found.
plugin/dapp/paracross/executor/superaccount_test.go
View file @
28e5ae03
...
...
@@ -320,6 +320,7 @@ func (suite *NodeManageTestSuite) testNodeConfig() {
func
(
suite
*
NodeManageTestSuite
)
TestExec
()
{
suite
.
testNodeGroupConfig
()
suite
.
testNodeConfig
()
suite
.
testSupervisionExec
()
}
func
TestNodeManageSuite
(
t
*
testing
.
T
)
{
...
...
plugin/dapp/paracross/executor/supervisionaccount.go
View file @
28e5ae03
...
...
@@ -12,57 +12,6 @@ import (
"github.com/pkg/errors"
)
func
(
a
*
action
)
checkValidSupervisionNode
(
config
*
pt
.
ParaNodeAddrConfig
)
(
bool
,
error
)
{
nodes
,
_
,
err
:=
getParacrossSupervisonNodes
(
a
.
db
,
config
.
Title
)
if
err
!=
nil
&&
!
isNotFound
(
err
)
{
return
false
,
errors
.
Wrapf
(
err
,
"getNodes for title:%s"
,
config
.
Title
)
}
//有可能申请地址和配置地址不是同一个
if
validNode
(
config
.
Addr
,
nodes
)
{
return
true
,
nil
}
return
false
,
nil
}
func
(
a
*
action
)
checkSupervisionNodeGroupExist
(
title
string
)
error
{
key
:=
calcParaSupervisionNodeGroupAddrsKey
(
title
)
value
,
err
:=
a
.
db
.
Get
(
key
)
if
err
!=
nil
&&
!
isNotFound
(
err
)
{
return
err
}
if
value
!=
nil
{
clog
.
Error
(
"node group apply, group existed"
)
return
pt
.
ErrParaSupervisionNodeGroupExisted
}
return
nil
}
func
getSupervisionNodeGroupStatus
(
db
dbm
.
KV
,
title
string
)
(
*
pt
.
ParaNodeGroupStatus
,
error
)
{
key
:=
calcParaSupervisionNodeGroupStatusKey
(
title
)
val
,
err
:=
db
.
Get
(
key
)
if
err
!=
nil
{
return
nil
,
err
}
var
status
pt
.
ParaNodeGroupStatus
err
=
types
.
Decode
(
val
,
&
status
)
return
&
status
,
err
}
func
getSupervisionNodeAddr
(
db
dbm
.
KV
,
title
,
addr
string
)
(
*
pt
.
ParaNodeAddrIdStatus
,
error
)
{
key
:=
calcParaSupervisionNodeAddrKey
(
title
,
addr
)
val
,
err
:=
db
.
Get
(
key
)
if
err
!=
nil
{
return
nil
,
err
}
var
status
pt
.
ParaNodeAddrIdStatus
err
=
types
.
Decode
(
val
,
&
status
)
return
&
status
,
err
}
func
makeSupervisionNodeGroupIDReceipt
(
addr
string
,
prev
,
current
*
pt
.
ParaNodeGroupStatus
)
*
types
.
Receipt
{
log
:=
&
pt
.
ReceiptParaNodeGroupConfig
{
Addr
:
addr
,
...
...
@@ -142,16 +91,6 @@ func makeParaSupervisionNodeStatusReceipt(fromAddr string, prev, current *pt.Par
}
}
func
supervisionSelfConsentInitStage
(
cfg
*
types
.
Chain33Config
)
*
types
.
Receipt
{
isEnable
:=
cfg
.
IsEnable
(
pt
.
ParaConsSubConf
+
"."
+
pt
.
ParaSelfConsInitConf
)
stage
:=
&
pt
.
SelfConsensStage
{
StartHeight
:
0
,
Enable
:
pt
.
ParaConfigYes
}
if
isEnable
{
stage
.
Enable
=
pt
.
ParaConfigNo
}
stages
:=
&
pt
.
SelfConsensStages
{
Items
:
[]
*
pt
.
SelfConsensStage
{
stage
}}
return
makeStageSupervisionGroupReceipt
(
nil
,
stages
)
}
func
makeStageSupervisionGroupReceipt
(
prev
,
current
*
pt
.
SelfConsensStages
)
*
types
.
Receipt
{
key
:=
[]
byte
(
fmt
.
Sprintf
(
paraSupervisionSelfConsensStages
))
log
:=
&
pt
.
ReceiptSelfConsStagesUpdate
{
Prev
:
prev
,
Current
:
current
}
...
...
@@ -169,6 +108,61 @@ func makeStageSupervisionGroupReceipt(prev, current *pt.SelfConsensStages) *type
}
}
func
makeParaSupervisionNodeGroupStatusReceipt
(
title
string
,
addr
string
,
prev
,
current
*
pt
.
ParaNodeGroupStatus
)
*
types
.
Receipt
{
key
:=
calcParaSupervisionNodeGroupStatusKey
(
title
)
log
:=
&
pt
.
ReceiptParaNodeGroupConfig
{
Addr
:
addr
,
Prev
:
prev
,
Current
:
current
,
}
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
[]
*
types
.
KeyValue
{
{
Key
:
key
,
Value
:
types
.
Encode
(
current
)},
},
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
pt
.
TyLogParaSupervisionNodeGroupStatusUpdate
,
Log
:
types
.
Encode
(
log
),
},
},
}
}
func
getSupervisionNodeGroupStatus
(
db
dbm
.
KV
,
title
string
)
(
*
pt
.
ParaNodeGroupStatus
,
error
)
{
key
:=
calcParaSupervisionNodeGroupStatusKey
(
title
)
val
,
err
:=
db
.
Get
(
key
)
if
err
!=
nil
{
return
nil
,
err
}
var
status
pt
.
ParaNodeGroupStatus
err
=
types
.
Decode
(
val
,
&
status
)
return
&
status
,
err
}
func
getSupervisionNodeAddr
(
db
dbm
.
KV
,
title
,
addr
string
)
(
*
pt
.
ParaNodeAddrIdStatus
,
error
)
{
key
:=
calcParaSupervisionNodeAddrKey
(
title
,
addr
)
val
,
err
:=
db
.
Get
(
key
)
if
err
!=
nil
{
return
nil
,
err
}
var
status
pt
.
ParaNodeAddrIdStatus
err
=
types
.
Decode
(
val
,
&
status
)
return
&
status
,
err
}
func
supervisionSelfConsentInitStage
(
cfg
*
types
.
Chain33Config
)
*
types
.
Receipt
{
isEnable
:=
cfg
.
IsEnable
(
pt
.
ParaConsSubConf
+
"."
+
pt
.
ParaSelfConsInitConf
)
stage
:=
&
pt
.
SelfConsensStage
{
StartHeight
:
0
,
Enable
:
pt
.
ParaConfigYes
}
if
isEnable
{
stage
.
Enable
=
pt
.
ParaConfigNo
}
stages
:=
&
pt
.
SelfConsensStages
{
Items
:
[]
*
pt
.
SelfConsensStage
{
stage
}}
return
makeStageSupervisionGroupReceipt
(
nil
,
stages
)
}
func
getSupervisionNodeGroupID
(
cfg
*
types
.
Chain33Config
,
db
dbm
.
KV
,
title
string
,
height
int64
,
id
string
)
(
*
pt
.
ParaNodeGroupStatus
,
error
)
{
if
pt
.
IsParaForkHeight
(
cfg
,
height
,
pt
.
ForkLoopCheckCommitTxDone
)
{
id
=
calcParaSupervisionNodeGroupIDKey
(
title
,
id
)
...
...
@@ -183,6 +177,33 @@ func getSupervisionNodeGroupID(cfg *types.Chain33Config, db dbm.KV, title string
return
&
status
,
err
}
func
(
a
*
action
)
checkValidSupervisionNode
(
config
*
pt
.
ParaNodeAddrConfig
)
(
bool
,
error
)
{
nodes
,
_
,
err
:=
getParacrossSupervisonNodes
(
a
.
db
,
config
.
Title
)
if
err
!=
nil
&&
!
isNotFound
(
err
)
{
return
false
,
errors
.
Wrapf
(
err
,
"getNodes for title:%s"
,
config
.
Title
)
}
//有可能申请地址和配置地址不是同一个
if
validNode
(
config
.
Addr
,
nodes
)
{
return
true
,
nil
}
return
false
,
nil
}
func
(
a
*
action
)
checkSupervisionNodeGroupExist
(
title
string
)
error
{
key
:=
calcParaSupervisionNodeGroupAddrsKey
(
title
)
value
,
err
:=
a
.
db
.
Get
(
key
)
if
err
!=
nil
&&
!
isNotFound
(
err
)
{
return
err
}
if
value
!=
nil
{
clog
.
Error
(
"node group apply, group existed"
)
return
pt
.
ErrParaSupervisionNodeGroupExisted
}
return
nil
}
func
(
a
*
action
)
supervisionNodeGroupCreate
(
status
*
pt
.
ParaNodeGroupStatus
)
(
*
types
.
Receipt
,
error
)
{
nodes
:=
strings
.
Split
(
status
.
TargetAddrs
,
","
)
...
...
@@ -364,27 +385,6 @@ func (a *action) supervisionNodeGroupApprove(config *pt.ParaNodeAddrConfig) (*ty
return
a
.
supervisionNodeGroupApproveApply
(
config
,
id
)
}
func
makeParaSupervisionNodeGroupStatusReceipt
(
title
string
,
addr
string
,
prev
,
current
*
pt
.
ParaNodeGroupStatus
)
*
types
.
Receipt
{
key
:=
calcParaSupervisionNodeGroupStatusKey
(
title
)
log
:=
&
pt
.
ReceiptParaNodeGroupConfig
{
Addr
:
addr
,
Prev
:
prev
,
Current
:
current
,
}
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
[]
*
types
.
KeyValue
{
{
Key
:
key
,
Value
:
types
.
Encode
(
current
)},
},
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
pt
.
TyLogParaSupervisionNodeGroupStatusUpdate
,
Log
:
types
.
Encode
(
log
),
},
},
}
}
func
(
a
*
action
)
supervisionNodeGroupApproveApply
(
config
*
pt
.
ParaNodeAddrConfig
,
apply
*
pt
.
ParaNodeGroupStatus
)
(
*
types
.
Receipt
,
error
)
{
err
:=
a
.
checkSupervisionNodeGroupExist
(
config
.
Title
)
if
err
!=
nil
{
...
...
plugin/dapp/paracross/executor/supervisionaccount_test.go
View file @
28e5ae03
package
executor
import
(
"fmt"
"github.com/33cn/chain33/types"
pt
"github.com/33cn/plugin/plugin/dapp/paracross/types"
"github.com/stretchr/testify/assert"
...
...
@@ -21,7 +19,7 @@ func createRawSupervisionNodeConfigTx(config *pt.ParaNodeAddrConfig) (*types.Tra
return
tx
,
nil
}
func
(
suite
*
NodeManageTestSuite
)
T
estSupervisionExec
()
{
func
(
suite
*
NodeManageTestSuite
)
t
estSupervisionExec
()
{
suite
.
testSupervisionNodeConfigQuit
()
suite
.
testSupervisionNodeConfigApprove
()
}
...
...
@@ -51,8 +49,6 @@ func (suite *NodeManageTestSuite) testSupervisionNodeConfigQuit() {
suite
.
Nil
(
err
)
receipt
=
nodeCommit
(
suite
,
PrivKey14K
,
tx
)
fmt
.
Println
(
"***"
,
receipt
)
fmt
.
Println
(
"***"
,
receipt
.
Logs
[
0
]
.
Ty
)
}
func
(
suite
*
NodeManageTestSuite
)
testSupervisionNodeConfigApprove
()
{
...
...
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