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
62467e44
Unverified
Commit
62467e44
authored
Jul 24, 2018
by
Péter Szilágyi
Committed by
GitHub
Jul 24, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #17206 from hadv/master
consensus/clique: replace bubble sort by golang stable sort
parents
d0082bb7
49f63deb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
snapshot.go
consensus/clique/snapshot.go
+13
-11
No files found.
consensus/clique/snapshot.go
View file @
62467e44
...
@@ -19,6 +19,7 @@ package clique
...
@@ -19,6 +19,7 @@ package clique
import
(
import
(
"bytes"
"bytes"
"encoding/json"
"encoding/json"
"sort"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
...
@@ -56,6 +57,13 @@ type Snapshot struct {
...
@@ -56,6 +57,13 @@ type Snapshot struct {
Tally
map
[
common
.
Address
]
Tally
`json:"tally"`
// Current vote tally to avoid recalculating
Tally
map
[
common
.
Address
]
Tally
`json:"tally"`
// Current vote tally to avoid recalculating
}
}
// signers implements the sort interface to allow sorting a list of addresses
type
signers
[]
common
.
Address
func
(
s
signers
)
Len
()
int
{
return
len
(
s
)
}
func
(
s
signers
)
Less
(
i
,
j
int
)
bool
{
return
bytes
.
Compare
(
s
[
i
][
:
],
s
[
j
][
:
])
<
0
}
func
(
s
signers
)
Swap
(
i
,
j
int
)
{
s
[
i
],
s
[
j
]
=
s
[
j
],
s
[
i
]
}
// newSnapshot creates a new snapshot with the specified startup parameters. This
// newSnapshot creates a new snapshot with the specified startup parameters. This
// method does not initialize the set of recent signers, so only ever use if for
// method does not initialize the set of recent signers, so only ever use if for
// the genesis block.
// the genesis block.
...
@@ -286,18 +294,12 @@ func (s *Snapshot) apply(headers []*types.Header) (*Snapshot, error) {
...
@@ -286,18 +294,12 @@ func (s *Snapshot) apply(headers []*types.Header) (*Snapshot, error) {
// signers retrieves the list of authorized signers in ascending order.
// signers retrieves the list of authorized signers in ascending order.
func
(
s
*
Snapshot
)
signers
()
[]
common
.
Address
{
func
(
s
*
Snapshot
)
signers
()
[]
common
.
Address
{
signers
:=
make
([]
common
.
Address
,
0
,
len
(
s
.
Signers
))
sigs
:=
make
([]
common
.
Address
,
0
,
len
(
s
.
Signers
))
for
signer
:=
range
s
.
Signers
{
for
sig
:=
range
s
.
Signers
{
signers
=
append
(
signers
,
signer
)
sigs
=
append
(
sigs
,
sig
)
}
for
i
:=
0
;
i
<
len
(
signers
);
i
++
{
for
j
:=
i
+
1
;
j
<
len
(
signers
);
j
++
{
if
bytes
.
Compare
(
signers
[
i
][
:
],
signers
[
j
][
:
])
>
0
{
signers
[
i
],
signers
[
j
]
=
signers
[
j
],
signers
[
i
]
}
}
}
}
return
signers
sort
.
Sort
(
signers
(
sigs
))
return
sigs
}
}
// inturn returns if a signer at a given block height is in-turn or not.
// inturn returns if a signer at a given block height is in-turn or not.
...
...
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