|
|
@ -19,7 +19,6 @@ package clique |
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"bytes" |
|
|
|
"bytes" |
|
|
|
"encoding/json" |
|
|
|
"encoding/json" |
|
|
|
"sort" |
|
|
|
|
|
|
|
"time" |
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
@ -29,6 +28,7 @@ import ( |
|
|
|
"github.com/ethereum/go-ethereum/ethdb" |
|
|
|
"github.com/ethereum/go-ethereum/ethdb" |
|
|
|
"github.com/ethereum/go-ethereum/log" |
|
|
|
"github.com/ethereum/go-ethereum/log" |
|
|
|
"github.com/ethereum/go-ethereum/params" |
|
|
|
"github.com/ethereum/go-ethereum/params" |
|
|
|
|
|
|
|
"golang.org/x/exp/slices" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// Vote represents a single vote that an authorized signer made to modify the
|
|
|
|
// Vote represents a single vote that an authorized signer made to modify the
|
|
|
@ -62,13 +62,6 @@ 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
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// signersAscending implements the sort interface to allow sorting a list of addresses
|
|
|
|
|
|
|
|
type signersAscending []common.Address |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
// 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.
|
|
|
@ -315,7 +308,7 @@ func (s *Snapshot) signers() []common.Address { |
|
|
|
for sig := range s.Signers { |
|
|
|
for sig := range s.Signers { |
|
|
|
sigs = append(sigs, sig) |
|
|
|
sigs = append(sigs, sig) |
|
|
|
} |
|
|
|
} |
|
|
|
sort.Sort(signersAscending(sigs)) |
|
|
|
slices.SortFunc(sigs, common.Address.Less) |
|
|
|
return sigs |
|
|
|
return sigs |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|