Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
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
张蕾
Geth-Modification
Commits
514659a0
Unverified
Commit
514659a0
authored
Jun 23, 2017
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
consensus/clique: minor cleanups
parent
db6e6950
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
clique.go
consensus/clique/clique.go
+7
-6
No files found.
consensus/clique/clique.go
View file @
514659a0
...
@@ -504,23 +504,25 @@ func (c *Clique) Prepare(chain consensus.ChainReader, header *types.Header) erro
...
@@ -504,23 +504,25 @@ func (c *Clique) Prepare(chain consensus.ChainReader, header *types.Header) erro
header
.
Nonce
=
types
.
BlockNonce
{}
header
.
Nonce
=
types
.
BlockNonce
{}
number
:=
header
.
Number
.
Uint64
()
number
:=
header
.
Number
.
Uint64
()
// Assemble the voting snapshot
// Assemble the voting snapshot to check which votes make sense
snap
,
err
:=
c
.
snapshot
(
chain
,
number
-
1
,
header
.
ParentHash
,
nil
)
snap
,
err
:=
c
.
snapshot
(
chain
,
number
-
1
,
header
.
ParentHash
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
if
number
%
c
.
config
.
Epoch
!=
0
{
if
number
%
c
.
config
.
Epoch
!=
0
{
// Get valid votes
c
.
lock
.
RLock
()
c
.
lock
.
RLock
()
var
addresses
[]
common
.
Address
// Gather all the proposals that make sense voting on
addresses
:=
make
([]
common
.
Address
,
0
,
len
(
c
.
proposals
))
for
address
,
authorize
:=
range
c
.
proposals
{
for
address
,
authorize
:=
range
c
.
proposals
{
if
snap
.
validVote
(
address
,
authorize
)
{
if
snap
.
validVote
(
address
,
authorize
)
{
addresses
=
append
(
addresses
,
address
)
addresses
=
append
(
addresses
,
address
)
}
}
}
}
// If there's pending proposals, cast a vote on them
if
len
(
addresses
)
>
0
{
if
len
(
addresses
)
>
0
{
index
:=
rand
.
Intn
(
len
(
addresses
))
header
.
Coinbase
=
addresses
[
rand
.
Intn
(
len
(
addresses
))]
header
.
Coinbase
=
addresses
[
index
]
if
c
.
proposals
[
header
.
Coinbase
]
{
if
c
.
proposals
[
header
.
Coinbase
]
{
copy
(
header
.
Nonce
[
:
],
nonceAuthVote
)
copy
(
header
.
Nonce
[
:
],
nonceAuthVote
)
}
else
{
}
else
{
...
@@ -529,7 +531,6 @@ func (c *Clique) Prepare(chain consensus.ChainReader, header *types.Header) erro
...
@@ -529,7 +531,6 @@ func (c *Clique) Prepare(chain consensus.ChainReader, header *types.Header) erro
}
}
c
.
lock
.
RUnlock
()
c
.
lock
.
RUnlock
()
}
}
// Set the correct difficulty
// Set the correct difficulty
header
.
Difficulty
=
diffNoTurn
header
.
Difficulty
=
diffNoTurn
if
snap
.
inturn
(
header
.
Number
.
Uint64
(),
c
.
signer
)
{
if
snap
.
inturn
(
header
.
Number
.
Uint64
(),
c
.
signer
)
{
...
...
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