aboutsummaryrefslogtreecommitdiffstats
path: root/consensus/clique/snapshot.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2018-09-10 22:12:39 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-09-11 21:40:00 +0800
commit4bb25042eb957662155079e06bb2efbdd866eb99 (patch)
tree87e6833f5c30b0bf2cec878f4689f689572c058b /consensus/clique/snapshot.go
parent10bac3664702f31228eafedecf31e9bf115f6c29 (diff)
downloaddexon-4bb25042eb957662155079e06bb2efbdd866eb99.tar
dexon-4bb25042eb957662155079e06bb2efbdd866eb99.tar.gz
dexon-4bb25042eb957662155079e06bb2efbdd866eb99.tar.bz2
dexon-4bb25042eb957662155079e06bb2efbdd866eb99.tar.lz
dexon-4bb25042eb957662155079e06bb2efbdd866eb99.tar.xz
dexon-4bb25042eb957662155079e06bb2efbdd866eb99.tar.zst
dexon-4bb25042eb957662155079e06bb2efbdd866eb99.zip
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
}