@@ -26,45 +26,45 @@ import (
2626 "github.com/ethereum/go-ethereum/params"
2727)
2828
29- // vote represents a single vote that an authorized signer made to modify the
29+ // Vote represents a single vote that an authorized signer made to modify the
3030// list of authorizations.
31- type vote struct {
31+ type Vote struct {
3232 Signer common.Address `json:"signer"` // Authorized signer that cast this vote
3333 Block uint64 `json:"block"` // Block number the vote was cast in (expire old votes)
3434 Address common.Address `json:"address"` // Account being voted on to change its authorization
3535 Authorize bool `json:"authorize"` // Whether to authorize or deauthorize the voted account
3636}
3737
38- // tally is a simple vote tally to keep the current score of votes. Votes that
38+ // Tally is a simple vote tally to keep the current score of votes. Votes that
3939// go against the proposal aren't counted since it's equivalent to not voting.
40- type tally struct {
40+ type Tally struct {
4141 Authorize bool `json:"authorize"` // Whether the vote it about authorizing or kicking someone
4242 Votes int `json:"votes"` // Number of votes until now wanting to pass the proposal
4343}
4444
45- // snapshot is the state of the authorization voting at a given point in time.
46- type snapshot struct {
45+ // Snapshot is the state of the authorization voting at a given point in time.
46+ type Snapshot struct {
4747 config * params.CliqueConfig // Consensus engine parameters to fine tune behavior
4848
4949 Number uint64 `json:"number"` // Block number where the snapshot was created
5050 Hash common.Hash `json:"hash"` // Block hash where the snapshot was created
5151 Signers map [common.Address ]struct {} `json:"signers"` // Set of authorized signers at this moment
5252 Recents map [uint64 ]common.Address `json:"recents"` // Set of recent signers for spam protections
53- Votes []* vote `json:"votes"` // List of votes cast in chronological order
54- Tally map [common.Address ]tally `json:"tally"` // Current vote tally to avoid recalculating
53+ Votes []* Vote `json:"votes"` // List of votes cast in chronological order
54+ Tally map [common.Address ]Tally `json:"tally"` // Current vote tally to avoid recalculating
5555}
5656
5757// newSnapshot create a new snapshot with the specified startup parameters. This
5858// method does not initialize the set of recent signers, so only ever use if for
5959// the genesis block.
60- func newSnapshot (config * params.CliqueConfig , number uint64 , hash common.Hash , signers []common.Address ) * snapshot {
61- snap := & snapshot {
60+ func newSnapshot (config * params.CliqueConfig , number uint64 , hash common.Hash , signers []common.Address ) * Snapshot {
61+ snap := & Snapshot {
6262 config : config ,
6363 Number : number ,
6464 Hash : hash ,
6565 Signers : make (map [common.Address ]struct {}),
6666 Recents : make (map [uint64 ]common.Address ),
67- Tally : make (map [common.Address ]tally ),
67+ Tally : make (map [common.Address ]Tally ),
6868 }
6969 for _ , signer := range signers {
7070 snap .Signers [signer ] = struct {}{}
@@ -73,12 +73,12 @@ func newSnapshot(config *params.CliqueConfig, number uint64, hash common.Hash, s
7373}
7474
7575// loadSnapshot loads an existing snapshot from the database.
76- func loadSnapshot (config * params.CliqueConfig , db ethdb.Database , hash common.Hash ) (* snapshot , error ) {
76+ func loadSnapshot (config * params.CliqueConfig , db ethdb.Database , hash common.Hash ) (* Snapshot , error ) {
7777 blob , err := db .Get (append ([]byte ("clique-" ), hash [:]... ))
7878 if err != nil {
7979 return nil , err
8080 }
81- snap := new (snapshot )
81+ snap := new (Snapshot )
8282 if err := json .Unmarshal (blob , snap ); err != nil {
8383 return nil , err
8484 }
@@ -88,7 +88,7 @@ func loadSnapshot(config *params.CliqueConfig, db ethdb.Database, hash common.Ha
8888}
8989
9090// store inserts the snapshot into the database.
91- func (s * snapshot ) store (db ethdb.Database ) error {
91+ func (s * Snapshot ) store (db ethdb.Database ) error {
9292 blob , err := json .Marshal (s )
9393 if err != nil {
9494 return err
@@ -97,15 +97,15 @@ func (s *snapshot) store(db ethdb.Database) error {
9797}
9898
9999// copy creates a deep copy of the snapshot, though not the individual votes.
100- func (s * snapshot ) copy () * snapshot {
101- cpy := & snapshot {
100+ func (s * Snapshot ) copy () * Snapshot {
101+ cpy := & Snapshot {
102102 config : s .config ,
103103 Number : s .Number ,
104104 Hash : s .Hash ,
105105 Signers : make (map [common.Address ]struct {}),
106106 Recents : make (map [uint64 ]common.Address ),
107- Votes : make ([]* vote , len (s .Votes )),
108- Tally : make (map [common.Address ]tally ),
107+ Votes : make ([]* Vote , len (s .Votes )),
108+ Tally : make (map [common.Address ]Tally ),
109109 }
110110 for signer := range s .Signers {
111111 cpy .Signers [signer ] = struct {}{}
@@ -122,7 +122,7 @@ func (s *snapshot) copy() *snapshot {
122122}
123123
124124// cast adds a new vote into the tally.
125- func (s * snapshot ) cast (address common.Address , authorize bool ) bool {
125+ func (s * Snapshot ) cast (address common.Address , authorize bool ) bool {
126126 // Ensure the vote is meaningful
127127 _ , signer := s .Signers [address ]
128128 if (signer && authorize ) || (! signer && ! authorize ) {
@@ -133,13 +133,13 @@ func (s *snapshot) cast(address common.Address, authorize bool) bool {
133133 old .Votes ++
134134 s .Tally [address ] = old
135135 } else {
136- s .Tally [address ] = tally {Authorize : authorize , Votes : 1 }
136+ s .Tally [address ] = Tally {Authorize : authorize , Votes : 1 }
137137 }
138138 return true
139139}
140140
141141// uncast removes a previously cast vote from the tally.
142- func (s * snapshot ) uncast (address common.Address , authorize bool ) bool {
142+ func (s * Snapshot ) uncast (address common.Address , authorize bool ) bool {
143143 // If there's no tally, it's a dangling vote, just drop
144144 tally , ok := s .Tally [address ]
145145 if ! ok {
@@ -161,7 +161,7 @@ func (s *snapshot) uncast(address common.Address, authorize bool) bool {
161161
162162// apply creates a new authorization snapshot by applying the given headers to
163163// the original one.
164- func (s * snapshot ) apply (headers []* types.Header ) (* snapshot , error ) {
164+ func (s * Snapshot ) apply (headers []* types.Header ) (* Snapshot , error ) {
165165 // Allow passing in no headers for cleaner code
166166 if len (headers ) == 0 {
167167 return s , nil
@@ -183,7 +183,7 @@ func (s *snapshot) apply(headers []*types.Header) (*snapshot, error) {
183183 number := header .Number .Uint64 ()
184184 if number % s .config .Epoch == 0 {
185185 snap .Votes = nil
186- snap .Tally = make (map [common.Address ]tally )
186+ snap .Tally = make (map [common.Address ]Tally )
187187 }
188188 // Delete the oldest signer from the recent list to allow it signing again
189189 if limit := uint64 (len (snap .Signers )/ 2 + 1 ); number >= limit {
@@ -226,7 +226,7 @@ func (s *snapshot) apply(headers []*types.Header) (*snapshot, error) {
226226 return nil , errInvalidVote
227227 }
228228 if snap .cast (header .Coinbase , authorize ) {
229- snap .Votes = append (snap .Votes , & vote {
229+ snap .Votes = append (snap .Votes , & Vote {
230230 Signer : signer ,
231231 Block : number ,
232232 Address : header .Coinbase ,
@@ -274,7 +274,7 @@ func (s *snapshot) apply(headers []*types.Header) (*snapshot, error) {
274274}
275275
276276// signers retrieves the list of authorized signers in ascending order.
277- func (s * snapshot ) signers () []common.Address {
277+ func (s * Snapshot ) signers () []common.Address {
278278 signers := make ([]common.Address , 0 , len (s .Signers ))
279279 for signer := range s .Signers {
280280 signers = append (signers , signer )
@@ -290,7 +290,7 @@ func (s *snapshot) signers() []common.Address {
290290}
291291
292292// inturn returns if a signer at a given block height is in-turn or not.
293- func (s * snapshot ) inturn (number uint64 , signer common.Address ) bool {
293+ func (s * Snapshot ) inturn (number uint64 , signer common.Address ) bool {
294294 signers , offset := s .signers (), 0
295295 for offset < len (signers ) && signers [offset ] != signer {
296296 offset ++
0 commit comments