aboutsummaryrefslogtreecommitdiffstats
path: root/consensus/clique/snapshot.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2018-09-17 16:35:42 +0800
committerGitHub <noreply@github.com>2018-09-17 16:35:42 +0800
commitcc21928e1246f860ede5160986ec3a95956fc8d4 (patch)
treeabc73a40bca6026c8addc3af2262b6446180777f /consensus/clique/snapshot.go
parent7c71e936a716794709e7a980b7da9010c4d0a98c (diff)
parent4bb25042eb957662155079e06bb2efbdd866eb99 (diff)
downloadgo-tangerine-cc21928e1246f860ede5160986ec3a95956fc8d4.tar
go-tangerine-cc21928e1246f860ede5160986ec3a95956fc8d4.tar.gz
go-tangerine-cc21928e1246f860ede5160986ec3a95956fc8d4.tar.bz2
go-tangerine-cc21928e1246f860ede5160986ec3a95956fc8d4.tar.lz
go-tangerine-cc21928e1246f860ede5160986ec3a95956fc8d4.tar.xz
go-tangerine-cc21928e1246f860ede5160986ec3a95956fc8d4.tar.zst
go-tangerine-cc21928e1246f860ede5160986ec3a95956fc8d4.zip
Merge pull request #17622 from karalabe/chain-maker-seal
consensus/clique, core: chain maker clique + error tests
Diffstat (limited to 'consensus/clique/snapshot.go')
-rw-r--r--consensus/clique/snapshot.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/consensus/clique/snapshot.go b/consensus/clique/snapshot.go
index 2333d6924..54d4555f3 100644
--- a/consensus/clique/snapshot.go
+++ b/consensus/clique/snapshot.go
@@ -57,12 +57,12 @@ type Snapshot struct {
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
+// signersAscending implements the sort interface to allow sorting a list of addresses
+type signersAscending []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] }
+func (s signersAscending) Len() int { return len(s) }
+func (s signersAscending) Less(i, j int) bool { return bytes.Compare(s[i][:], s[j][:]) < 0 }
+func (s signersAscending) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
// 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
@@ -214,11 +214,11 @@ func (s *Snapshot) apply(headers []*types.Header) (*Snapshot, error) {
return nil, err
}
if _, ok := snap.Signers[signer]; !ok {
- return nil, errUnauthorized
+ return nil, errUnauthorizedSigner
}
for _, recent := range snap.Recents {
if recent == signer {
- return nil, errUnauthorized
+ return nil, errRecentlySigned
}
}
snap.Recents[number] = signer
@@ -298,7 +298,7 @@ func (s *Snapshot) signers() []common.Address {
for sig := range s.Signers {
sigs = append(sigs, sig)
}
- sort.Sort(signers(sigs))
+ sort.Sort(signersAscending(sigs))
return sigs
}