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
71eeae1c
Commit
71eeae1c
authored
Sep 17, 2020
by
QM
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updata
parent
6ebd67fb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
23 deletions
+25
-23
parablssign.go
plugin/consensus/para/parablssign.go
+9
-21
action.go
plugin/dapp/paracross/executor/action.go
+16
-2
No files found.
plugin/consensus/para/parablssign.go
View file @
71eeae1c
...
@@ -172,38 +172,26 @@ func (b *blsClient) getLeaderInfo() ([]string, int32, int32, int32, bool) {
...
@@ -172,38 +172,26 @@ func (b *blsClient) getLeaderInfo() ([]string, int32, int32, int32, bool) {
return
nodes
,
leaderIdx
,
baseIdx
,
offIdx
,
nodes
[
leaderIdx
]
==
b
.
selfID
return
nodes
,
leaderIdx
,
baseIdx
,
offIdx
,
nodes
[
leaderIdx
]
==
b
.
selfID
}
}
func
(
b
*
blsClient
)
getSupervisionLeaderInfo
()
([]
string
,
int32
,
int32
,
int32
,
bool
)
{
//在未同步前 不处理聚合消息
if
!
b
.
paraClient
.
commitMsgClient
.
isSync
()
{
return
nil
,
0
,
0
,
0
,
false
}
supervisionNodes
,
_
:=
b
.
getSupervisionSuperNodes
()
if
len
(
supervisionNodes
)
<=
0
{
return
nil
,
0
,
0
,
0
,
false
}
h
:=
b
.
paraClient
.
commitMsgClient
.
getConsensusHeight
()
//间隔的除数再根据nodes取余数,平均覆盖所有节点
baseIdx
:=
int32
((
h
/
int64
(
b
.
leaderSwitchInt
))
%
int64
(
len
(
supervisionNodes
)))
offIdx
:=
atomic
.
LoadInt32
(
&
b
.
leaderOffset
)
leaderIdx
:=
(
baseIdx
+
offIdx
)
%
int32
(
len
(
supervisionNodes
))
return
supervisionNodes
,
leaderIdx
,
baseIdx
,
offIdx
,
supervisionNodes
[
leaderIdx
]
==
b
.
selfID
}
func
(
b
*
blsClient
)
getSuperNodes
()
([]
string
,
string
)
{
func
(
b
*
blsClient
)
getSuperNodes
()
([]
string
,
string
)
{
// 获取授权节点
nodeStr
,
err
:=
b
.
paraClient
.
commitMsgClient
.
getNodeGroupAddrs
()
nodeStr
,
err
:=
b
.
paraClient
.
commitMsgClient
.
getNodeGroupAddrs
()
if
strings
.
Contains
(
nodeStr
,
b
.
selfID
)
{
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
""
return
nil
,
""
}
}
return
strings
.
Split
(
nodeStr
,
","
),
nodeStr
return
strings
.
Split
(
nodeStr
,
","
),
nodeStr
}
}
// 获取监督节点
// 获取监督节点
func
(
b
*
blsClient
)
getSupervisionSuperNodes
()
([]
string
,
string
)
{
nodeStr
,
err
=
b
.
paraClient
.
commitMsgClient
.
getSupervisionNodeGroupAddrs
()
nodeStr
,
err
:=
b
.
paraClient
.
commitMsgClient
.
getSupervisionNodeGroupAddrs
()
if
strings
.
Contains
(
nodeStr
,
b
.
selfID
)
{
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
""
return
nil
,
""
}
}
return
strings
.
Split
(
nodeStr
,
","
),
nodeStr
return
strings
.
Split
(
nodeStr
,
","
),
nodeStr
}
return
nil
,
""
}
}
func
(
b
*
blsClient
)
isValidNodes
(
id
string
)
bool
{
func
(
b
*
blsClient
)
isValidNodes
(
id
string
)
bool
{
...
...
plugin/dapp/paracross/executor/action.go
View file @
71eeae1c
...
@@ -547,6 +547,8 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
...
@@ -547,6 +547,8 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
var
commitAddrs
,
commitSupervisionAddrs
,
validAddrs
,
supervisionValidAddrs
[]
string
var
commitAddrs
,
commitSupervisionAddrs
,
validAddrs
,
supervisionValidAddrs
[]
string
bIsCommitSuperNode
:=
false
bIsCommitSupervisionNode
:=
false
for
_
,
addr
:=
range
nodesArry
{
for
_
,
addr
:=
range
nodesArry
{
if
addr
==
a
.
fromaddr
{
if
addr
==
a
.
fromaddr
{
// 授权节点共识
// 授权节点共识
...
@@ -561,6 +563,11 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
...
@@ -561,6 +563,11 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
}
}
validAddrs
=
getValidAddrs
(
nodesMap
,
commitAddrs
)
validAddrs
=
getValidAddrs
(
nodesMap
,
commitAddrs
)
if
len
(
validAddrs
)
<=
0
{
return
nil
,
errors
.
Wrapf
(
err
,
"getValidAddrs nil commitAddrs=%s "
,
strings
.
Join
(
commitAddrs
,
","
))
}
bIsCommitSuperNode
=
true
break
break
}
}
}
}
...
@@ -571,6 +578,7 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
...
@@ -571,6 +578,7 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
return
nil
,
errors
.
Wrap
(
err
,
"getSupervisionNodesGroup"
)
return
nil
,
errors
.
Wrap
(
err
,
"getSupervisionNodesGroup"
)
}
}
if
!
bIsCommitSuperNode
{
for
_
,
addr
:=
range
supervisionNodesArry
{
for
_
,
addr
:=
range
supervisionNodesArry
{
if
addr
==
a
.
fromaddr
{
if
addr
==
a
.
fromaddr
{
// 监督节点共识
// 监督节点共识
...
@@ -585,12 +593,18 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
...
@@ -585,12 +593,18 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
}
}
supervisionValidAddrs
=
getValidAddrs
(
supervisionNodesMap
,
commitSupervisionAddrs
)
supervisionValidAddrs
=
getValidAddrs
(
supervisionNodesMap
,
commitSupervisionAddrs
)
if
len
(
supervisionValidAddrs
)
<=
0
{
return
nil
,
errors
.
Wrapf
(
err
,
"getValidAddrs nil commitSupervisionAddrs=%s"
,
strings
.
Join
(
commitSupervisionAddrs
,
","
))
}
bIsCommitSupervisionNode
=
true
break
break
}
}
}
}
}
if
len
(
validAddrs
)
<=
0
&&
len
(
supervisionValidAddrs
)
<=
0
{
if
!
bIsCommitSuperNode
&&
!
bIsCommitSupervisionNode
{
return
nil
,
errors
.
Wrapf
(
err
,
"getValidAddrs nil commitAddrs=%s commitSupervisionAddrs=%s"
,
strings
.
Join
(
commitAddrs
,
","
),
strings
.
Join
(
commitSupervisionAddrs
,
","
)
)
return
nil
,
errors
.
Wrapf
(
err
ors
.
New
(
"from addr error"
),
"form addr %s not in SuperNodesGroup, not in SupervisionNodesGroup"
,
a
.
fromaddr
)
}
}
return
a
.
proCommitMsg
(
commit
.
Status
,
nodesMap
,
validAddrs
,
supervisionNodesMap
,
supervisionValidAddrs
)
return
a
.
proCommitMsg
(
commit
.
Status
,
nodesMap
,
validAddrs
,
supervisionNodesMap
,
supervisionValidAddrs
)
...
...
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