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
da88bf4b
Commit
da88bf4b
authored
Nov 25, 2020
by
QM
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add supervision node modify
parent
3eb5918e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
7 deletions
+62
-7
paracross.go
plugin/dapp/paracross/commands/paracross.go
+39
-0
supervisionaccount.go
plugin/dapp/paracross/executor/supervisionaccount.go
+22
-7
paracross.go
plugin/dapp/paracross/types/paracross.go
+1
-0
No files found.
plugin/dapp/paracross/commands/paracross.go
View file @
da88bf4b
...
...
@@ -1525,6 +1525,7 @@ func supervisionNodeCmd() *cobra.Command {
cmd
.
AddCommand
(
getSupervisionNodeGroupAddrsCmd
())
cmd
.
AddCommand
(
supervisionNodeListInfoCmd
())
cmd
.
AddCommand
(
getSupervisionNodeInfoCmd
())
cmd
.
AddCommand
(
supervisionNodeModifyCmd
())
return
cmd
}
...
...
@@ -1774,3 +1775,41 @@ func supervisionNodeInfo(cmd *cobra.Command, args []string) {
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
.
Run
()
}
func
supervisionNodeModifyCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"modify"
,
Short
:
"supervision node modify parameters"
,
Run
:
createSupervisionNodeModifyTx
,
}
addSupervisionNodeModifyFlags
(
cmd
)
return
cmd
}
func
addSupervisionNodeModifyFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"addr"
,
"a"
,
""
,
"operating target apply id"
)
_
=
cmd
.
MarkFlagRequired
(
"addr"
)
cmd
.
Flags
()
.
StringP
(
"pubkey"
,
"p"
,
""
,
"operating target apply id"
)
_
=
cmd
.
MarkFlagRequired
(
"pubkey"
)
}
func
createSupervisionNodeModifyTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
paraName
,
_
:=
cmd
.
Flags
()
.
GetString
(
"paraName"
)
addr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr"
)
pubkey
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkey"
)
if
!
strings
.
HasPrefix
(
paraName
,
"user.p"
)
{
_
,
_
=
fmt
.
Fprintln
(
os
.
Stderr
,
"paraName is not right, paraName format like `user.p.guodun.`"
)
return
}
payload
:=
&
pt
.
ParaNodeAddrConfig
{
Title
:
paraName
,
Op
:
pt
.
ParacrossSupervisionNodeModify
,
Addr
:
addr
,
BlsPubKey
:
pubkey
}
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
getRealExecName
(
paraName
,
pt
.
ParaX
),
ActionName
:
"SupervisionNodeConfig"
,
Payload
:
types
.
MustPBToJSON
(
payload
),
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"Chain33.CreateTransaction"
,
params
,
nil
)
ctx
.
RunWithoutMarshal
()
}
plugin/dapp/paracross/executor/supervisionaccount.go
View file @
da88bf4b
package
executor
import
(
"fmt"
"github.com/33cn/chain33/common"
dbm
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/types"
...
...
@@ -228,18 +226,16 @@ func (a *action) supervisionNodeApply(config *pt.ParaNodeAddrConfig) (*types.Rec
// 不能跟授权节点一致
if
addrExist
{
clog
.
Debug
(
"supervisionNodeGroup Apply"
,
"config.Addr"
,
config
.
Addr
,
"err"
,
"config.Addr existed in super group"
)
return
nil
,
pt
.
ErrParaNodeAddrExisted
return
nil
,
errors
.
Wrapf
(
pt
.
ErrParaNodeAddrExisted
,
"supervisionNodeGroup Apply Addr existed:%s in super group"
,
config
.
Addr
)
}
// 判断 node 是否已经申请
addrExist
,
err
=
a
.
checkValidSupervisionNode
(
config
)
if
err
!=
nil
{
fmt
.
Println
(
"err:"
,
err
)
return
nil
,
err
}
if
addrExist
{
clog
.
Debug
(
"supervisionNodeGroup Apply"
,
"config.Addr"
,
config
.
Addr
,
"err"
,
"config.Addr existed in supervision group"
)
return
nil
,
pt
.
ErrParaSupervisionNodeAddrExisted
return
nil
,
errors
.
Wrapf
(
pt
.
ErrParaSupervisionNodeAddrExisted
,
"supervisionNodeGroup Apply Addr existed:%s"
,
config
.
Addr
)
}
// 在主链上冻结金额
...
...
@@ -426,6 +422,23 @@ func (a *action) supervisionNodeCancel(config *pt.ParaNodeAddrConfig) (*types.Re
return
receipt
,
nil
}
func
(
a
*
action
)
supervisionNodeModify
(
config
*
pt
.
ParaNodeAddrConfig
)
(
*
types
.
Receipt
,
error
)
{
addrStat
,
err
:=
getNodeAddr
(
a
.
db
,
config
.
Title
,
config
.
Addr
)
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"nodeAddr:%s get error"
,
config
.
Addr
)
}
// 只能提案发起人
if
a
.
fromaddr
!=
config
.
Addr
{
return
nil
,
errors
.
Wrapf
(
types
.
ErrNotAllow
,
"addr create by:%s,not by:%s"
,
config
.
Addr
,
a
.
fromaddr
)
}
preStat
:=
*
addrStat
addrStat
.
BlsPubKey
=
config
.
BlsPubKey
return
makeParaSupervisionNodeStatusReceipt
(
a
.
fromaddr
,
&
preStat
,
addrStat
),
nil
}
func
(
a
*
action
)
SupervisionNodeConfig
(
config
*
pt
.
ParaNodeAddrConfig
)
(
*
types
.
Receipt
,
error
)
{
cfg
:=
a
.
api
.
GetConfig
()
if
!
validTitle
(
cfg
,
config
.
Title
)
{
...
...
@@ -448,6 +461,8 @@ func (a *action) SupervisionNodeConfig(config *pt.ParaNodeAddrConfig) (*types.Re
}
else
if
config
.
Op
==
pt
.
ParacrossSupervisionNodeCancel
{
// 撤销未批准的申请
return
a
.
supervisionNodeCancel
(
config
)
}
else
if
config
.
Op
==
pt
.
ParacrossSupervisionNodeModify
{
return
a
.
supervisionNodeModify
(
config
)
}
return
nil
,
pt
.
ErrParaUnSupportNodeOper
...
...
plugin/dapp/paracross/types/paracross.go
View file @
da88bf4b
...
...
@@ -175,6 +175,7 @@ const (
ParacrossSupervisionNodeApprove
ParacrossSupervisionNodeQuit
ParacrossSupervisionNodeCancel
ParacrossSupervisionNodeModify
)
// 0 普通节点共识 1 授权节点正在共识 2 监督节点正在共识
...
...
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