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
cfa64635
Commit
cfa64635
authored
Jun 04, 2019
by
mdj33
Committed by
vipwzw
Jun 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update vote addrs by current nodes
parent
88c8c405
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
1 deletion
+51
-1
docker-compose.sh
build/docker-compose.sh
+1
-0
action.go
plugin/dapp/paracross/executor/action.go
+18
-0
superaccount.go
plugin/dapp/paracross/executor/superaccount.go
+16
-1
superaccount_test.go
plugin/dapp/paracross/executor/superaccount_test.go
+16
-0
No files found.
build/docker-compose.sh
View file @
cfa64635
...
...
@@ -98,6 +98,7 @@ function base_init() {
sed
-i
$sedfix
's/^minerdisable=.*/minerdisable=false/g'
chain33.toml
sed
-i
$sedfix
's/^nodeGroupFrozenCoins=.*/nodeGroupFrozenCoins=20/g'
chain33.toml
sed
-i
$sedfix
's/^paraConsensusStopBlocks=.*/paraConsensusStopBlocks=100/g'
chain33.toml
# ticket
sed
-i
$sedfix
's/^ticketPrice =.*/ticketPrice = 10000/g'
chain33.toml
...
...
plugin/dapp/paracross/executor/action.go
View file @
cfa64635
...
...
@@ -260,6 +260,19 @@ func (a *action) getNodesGroup(title string) (map[string]struct{}, error) {
return
nodes
,
nil
}
//根据nodes过滤掉可能退出了的addrs
func
updateCommitAddrs
(
stat
*
pt
.
ParacrossHeightStatus
,
nodes
map
[
string
]
struct
{}){
details
:=
&
pt
.
ParacrossStatusDetails
{}
for
i
,
addr
:=
range
stat
.
Details
.
Addrs
{
if
_
,
ok
:=
nodes
[
addr
];
ok
{
details
.
Addrs
=
append
(
details
.
Addrs
,
addr
)
details
.
BlockHash
=
append
(
details
.
BlockHash
,
stat
.
Details
.
BlockHash
[
i
])
}
}
stat
.
Details
=
details
}
func
(
a
*
action
)
Commit
(
commit
*
pt
.
ParacrossCommitAction
)
(
*
types
.
Receipt
,
error
)
{
err
:=
checkCommitInfo
(
commit
)
if
err
!=
nil
{
...
...
@@ -364,6 +377,11 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
}
receipt
=
makeCommitReceipt
(
a
.
fromaddr
,
commit
,
&
copyStat
,
stat
)
}
if
types
.
IsDappFork
(
commit
.
Status
.
MainBlockHeight
,
pt
.
ParaX
,
pt
.
ForkCommitTx
){
updateCommitAddrs
(
stat
,
nodes
)
}
clog
.
Info
(
"paracross.Commit commit"
,
"stat.title"
,
stat
.
Title
,
"stat.height"
,
stat
.
Height
,
"notes"
,
len
(
nodes
))
for
i
,
v
:=
range
stat
.
Details
.
Addrs
{
clog
.
Info
(
"paracross.Commit commit detail"
,
"addr"
,
v
,
"hash"
,
hex
.
EncodeToString
(
stat
.
Details
.
BlockHash
[
i
]))
...
...
plugin/dapp/paracross/executor/superaccount.go
View file @
cfa64635
...
...
@@ -395,12 +395,23 @@ func (a *action) superManagerVoteProc(title string) error {
//return err to stop tx pass to para chain
if
a
.
height
<=
consensMainHeight
+
confStopBlocks
{
return
errors
.
Wrapf
(
pt
.
ErrParaConsensStopBlocksNotReach
,
"supermanager height not reach,current:%d less consens:%d plus confStopBlocks:%
s
"
,
a
.
height
,
consensMainHeight
,
confStopBlocks
)
"supermanager height not reach,current:%d less consens:%d plus confStopBlocks:%
d
"
,
a
.
height
,
consensMainHeight
,
confStopBlocks
)
}
return
nil
}
func
updateVotes
(
stat
*
pt
.
ParaNodeIdStatus
,
nodes
map
[
string
]
struct
{}){
votes
:=
&
pt
.
ParaNodeVoteDetail
{}
for
i
,
addr
:=
range
stat
.
Votes
.
Addrs
{
if
_
,
ok
:=
nodes
[
addr
];
ok
{
votes
.
Addrs
=
append
(
votes
.
Addrs
,
addr
)
votes
.
Votes
=
append
(
votes
.
Votes
,
stat
.
Votes
.
Votes
[
i
])
}
}
stat
.
Votes
=
votes
}
func
(
a
*
action
)
nodeVote
(
config
*
pt
.
ParaNodeAddrConfig
)
(
*
types
.
Receipt
,
error
)
{
nodes
,
_
,
err
:=
getParacrossNodes
(
a
.
db
,
config
.
Title
)
if
err
!=
nil
{
...
...
@@ -436,6 +447,10 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
stat
.
Votes
.
Addrs
=
append
(
stat
.
Votes
.
Addrs
,
a
.
fromaddr
)
stat
.
Votes
.
Votes
=
append
(
stat
.
Votes
.
Votes
,
pt
.
ParaNodeVoteStr
[
config
.
Value
])
}
//剔除已退出nodegroup的addr的投票
updateVotes
(
stat
,
nodes
)
most
,
vote
:=
getMostVote
(
stat
)
if
!
isCommitDone
(
stat
,
nodes
,
most
)
{
superManagerPass
:=
false
...
...
plugin/dapp/paracross/executor/superaccount_test.go
View file @
cfa64635
...
...
@@ -352,3 +352,18 @@ func TestGetAddrGroup(t *testing.T) {
assert
.
Equal
(
t
,
0
,
len
(
ret
))
}
func
TestUpdateVotes
(
t
*
testing
.
T
){
stat
:=
&
pt
.
ParaNodeIdStatus
{}
votes
:=
&
pt
.
ParaNodeVoteDetail
{
Addrs
:
[]
string
{
"AA"
,
"BB"
,
"CC"
},
Votes
:
[]
string
{
"yes"
,
"no"
,
"no"
}}
stat
.
Votes
=
votes
nodes
:=
make
(
map
[
string
]
struct
{})
nodes
[
"BB"
]
=
struct
{}{}
nodes
[
"CC"
]
=
struct
{}{}
updateVotes
(
stat
,
nodes
)
assert
.
Equal
(
t
,[]
string
{
"BB"
,
"CC"
},
stat
.
Votes
.
Addrs
)
assert
.
Equal
(
t
,[]
string
{
"no"
,
"no"
},
stat
.
Votes
.
Votes
)
}
\ No newline at end of file
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