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
e98a4ba2
Commit
e98a4ba2
authored
Nov 06, 2020
by
QM
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updata
parent
40248d1c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
26 deletions
+9
-26
supervisionaccount.go
plugin/dapp/paracross/executor/supervisionaccount.go
+9
-26
No files found.
plugin/dapp/paracross/executor/supervisionaccount.go
View file @
e98a4ba2
...
@@ -104,12 +104,11 @@ func (a *action) updateSupervisionNodeGroup(title, addr string, add bool) (*type
...
@@ -104,12 +104,11 @@ func (a *action) updateSupervisionNodeGroup(title, addr string, add bool) (*type
copyItem
.
Value
=
&
types
.
ConfigItem_Arr
{
Arr
:
&
copyValue
}
copyItem
.
Value
=
&
types
.
ConfigItem_Arr
{
Arr
:
&
copyValue
}
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
}
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
}
item
.
Addr
=
addr
if
add
{
if
add
{
item
.
GetArr
()
.
Value
=
append
(
item
.
GetArr
()
.
Value
,
addr
)
item
.
GetArr
()
.
Value
=
append
(
item
.
GetArr
()
.
Value
,
addr
)
item
.
Addr
=
addr
clog
.
Info
(
"updateSupervisionNodeGroup add"
,
"addr"
,
addr
)
clog
.
Info
(
"updateSupervisionNodeGroup add"
,
"addr"
,
addr
)
}
else
{
}
else
{
item
.
Addr
=
addr
item
.
GetArr
()
.
Value
=
make
([]
string
,
0
)
item
.
GetArr
()
.
Value
=
make
([]
string
,
0
)
for
_
,
value
:=
range
copyItem
.
GetArr
()
.
Value
{
for
_
,
value
:=
range
copyItem
.
GetArr
()
.
Value
{
if
value
!=
addr
{
if
value
!=
addr
{
...
@@ -140,11 +139,11 @@ func (a *action) checkValidSupervisionNode(config *pt.ParaNodeAddrConfig) (bool,
...
@@ -140,11 +139,11 @@ func (a *action) checkValidSupervisionNode(config *pt.ParaNodeAddrConfig) (bool,
return
false
,
nil
return
false
,
nil
}
}
func
(
a
*
action
)
checkSupervisionNodeGroupExist
(
title
string
)
(
error
,
bool
)
{
func
(
a
*
action
)
checkSupervisionNodeGroupExist
(
title
string
)
(
bool
,
error
)
{
key
:=
calcParaSupervisionNodeGroupAddrsKey
(
title
)
key
:=
calcParaSupervisionNodeGroupAddrsKey
(
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
,
false
return
false
,
err
}
}
if
value
!=
nil
{
if
value
!=
nil
{
...
@@ -152,13 +151,13 @@ func (a *action) checkSupervisionNodeGroupExist(title string) (error, bool) {
...
@@ -152,13 +151,13 @@ func (a *action) checkSupervisionNodeGroupExist(title string) (error, bool) {
err
=
types
.
Decode
(
value
,
&
item
)
err
=
types
.
Decode
(
value
,
&
item
)
if
err
!=
nil
{
if
err
!=
nil
{
clog
.
Error
(
"updateSupervisionNodeGroup"
,
"decode db key"
,
key
)
clog
.
Error
(
"updateSupervisionNodeGroup"
,
"decode db key"
,
key
)
return
err
,
false
return
false
,
err
}
}
return
nil
,
true
return
true
,
nil
}
}
return
nil
,
false
return
false
,
nil
}
}
func
(
a
*
action
)
supervisionNodeGroupCreate
(
title
,
targetAddrs
string
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
supervisionNodeGroupCreate
(
title
,
targetAddrs
string
)
(
*
types
.
Receipt
,
error
)
{
...
@@ -175,18 +174,6 @@ func (a *action) supervisionNodeGroupCreate(title, targetAddrs string) (*types.R
...
@@ -175,18 +174,6 @@ func (a *action) supervisionNodeGroupCreate(title, targetAddrs string) (*types.R
return
receipt
,
nil
return
receipt
,
nil
}
}
func
getSupervisionNodeAddr
(
db
dbm
.
KV
,
title
,
addr
string
)
(
*
pt
.
ParaNodeAddrIdStatus
,
error
)
{
key
:=
calcParaNodeAddrKey
(
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
}
//由于propasal id 和quit id分开,quit id不知道对应addr proposal id的coinfrozen信息,需要维护一个围绕addr的数据库结构信息
//由于propasal id 和quit id分开,quit id不知道对应addr proposal id的coinfrozen信息,需要维护一个围绕addr的数据库结构信息
func
(
a
*
action
)
updateSupervisionNodeAddrStatus
(
stat
*
pt
.
ParaNodeIdStatus
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
updateSupervisionNodeAddrStatus
(
stat
*
pt
.
ParaNodeIdStatus
)
(
*
types
.
Receipt
,
error
)
{
addrStat
,
err
:=
getNodeAddr
(
a
.
db
,
stat
.
Title
,
stat
.
TargetAddr
)
addrStat
,
err
:=
getNodeAddr
(
a
.
db
,
stat
.
Title
,
stat
.
TargetAddr
)
...
@@ -293,24 +280,22 @@ func (a *action) supervisionNodeApprove(config *pt.ParaNodeAddrConfig) (*types.R
...
@@ -293,24 +280,22 @@ func (a *action) supervisionNodeApprove(config *pt.ParaNodeAddrConfig) (*types.R
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
config
.
Title
!=
apply
.
Title
{
if
config
.
Title
!=
apply
.
Title
{
return
nil
,
errors
.
Wrapf
(
pt
.
ErrNodeNotForTheTitle
,
"config title:%s,id title:%s"
,
config
.
Title
,
apply
.
Title
)
return
nil
,
errors
.
Wrapf
(
pt
.
ErrNodeNotForTheTitle
,
"config title:%s,id title:%s"
,
config
.
Title
,
apply
.
Title
)
}
}
if
apply
.
CoinsFrozen
<
config
.
CoinsFrozen
{
if
apply
.
CoinsFrozen
<
config
.
CoinsFrozen
{
return
nil
,
errors
.
Wrapf
(
pt
.
ErrParaNodeGroupFrozenCoinsNotEnough
,
"id not enough coins apply:%d,config:%d"
,
apply
.
CoinsFrozen
,
config
.
CoinsFrozen
)
return
nil
,
errors
.
Wrapf
(
pt
.
ErrParaNodeGroupFrozenCoinsNotEnough
,
"id not enough coins apply:%d,config:%d"
,
apply
.
CoinsFrozen
,
config
.
CoinsFrozen
)
}
}
// 判断监督账户组是否已经存在
// 判断监督账户组是否已经存在
e
rr
,
exist
:=
a
.
checkSupervisionNodeGroupExist
(
config
.
Title
)
e
xist
,
err
:=
a
.
checkSupervisionNodeGroupExist
(
config
.
Title
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
}
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
}
// 监督账户组不存在
if
!
exist
{
if
!
exist
{
// 监督账户组不存在
r
,
err
:=
a
.
supervisionNodeGroupCreate
(
apply
.
Title
,
apply
.
TargetAddr
)
r
,
err
:=
a
.
supervisionNodeGroupCreate
(
apply
.
Title
,
apply
.
TargetAddr
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"nodegroup create:title:%s,addrs:%s"
,
config
.
Title
,
apply
.
TargetAddr
)
return
nil
,
errors
.
Wrapf
(
err
,
"nodegroup create:title:%s,addrs:%s"
,
config
.
Title
,
apply
.
TargetAddr
)
...
@@ -349,7 +334,7 @@ func (a *action) supervisionNodeQuit(config *pt.ParaNodeAddrConfig) (*types.Rece
...
@@ -349,7 +334,7 @@ func (a *action) supervisionNodeQuit(config *pt.ParaNodeAddrConfig) (*types.Rece
return
nil
,
errors
.
Wrapf
(
pt
.
ErrParaSupervisionNodeAddrNotExisted
,
"nodeAddr not existed:%s"
,
config
.
Addr
)
return
nil
,
errors
.
Wrapf
(
pt
.
ErrParaSupervisionNodeAddrNotExisted
,
"nodeAddr not existed:%s"
,
config
.
Addr
)
}
}
status
,
err
:=
get
Supervision
NodeAddr
(
a
.
db
,
config
.
Title
,
config
.
Addr
)
status
,
err
:=
getNodeAddr
(
a
.
db
,
config
.
Title
,
config
.
Addr
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"nodeAddr:%s get error"
,
config
.
Addr
)
return
nil
,
errors
.
Wrapf
(
err
,
"nodeAddr:%s get error"
,
config
.
Addr
)
}
}
...
@@ -414,11 +399,9 @@ func (a *action) supervisionNodeCancel(config *pt.ParaNodeAddrConfig) (*types.Re
...
@@ -414,11 +399,9 @@ func (a *action) supervisionNodeCancel(config *pt.ParaNodeAddrConfig) (*types.Re
if
a
.
fromaddr
!=
status
.
FromAddr
{
if
a
.
fromaddr
!=
status
.
FromAddr
{
return
nil
,
errors
.
Wrapf
(
types
.
ErrNotAllow
,
"id create by:%s,not by:%s"
,
status
.
FromAddr
,
a
.
fromaddr
)
return
nil
,
errors
.
Wrapf
(
types
.
ErrNotAllow
,
"id create by:%s,not by:%s"
,
status
.
FromAddr
,
a
.
fromaddr
)
}
}
if
config
.
Title
!=
status
.
Title
{
if
config
.
Title
!=
status
.
Title
{
return
nil
,
errors
.
Wrapf
(
pt
.
ErrNodeNotForTheTitle
,
"config title:%s,id title:%s"
,
config
.
Title
,
status
.
Title
)
return
nil
,
errors
.
Wrapf
(
pt
.
ErrNodeNotForTheTitle
,
"config title:%s,id title:%s"
,
config
.
Title
,
status
.
Title
)
}
}
if
status
.
Status
!=
pt
.
ParacrossSupervisionNodeApply
{
if
status
.
Status
!=
pt
.
ParacrossSupervisionNodeApply
{
return
nil
,
errors
.
Wrapf
(
pt
.
ErrParaNodeOpStatusWrong
,
"config id:%s,status:%d"
,
config
.
Id
,
status
.
Status
)
return
nil
,
errors
.
Wrapf
(
pt
.
ErrParaNodeOpStatusWrong
,
"config id:%s,status:%d"
,
config
.
Id
,
status
.
Status
)
}
}
...
...
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