// Consolidate votes from our peers to figure out if our latest state if out-of-date.
Consolidate votes from our peers to figure out if our latest state if out-of-date.
// Consolidate votes from our peers to figure out if our latest state if out - of - date .
func (s *SyncManager) consolidateVotesFromPeers(sampler *Snowball, votes <-chan Vote) {
	slice := make([]Vote, 0, cap(votes))
	voters := make(map[AccountID]struct{}, cap(votes))
	for vote := range votes {
		vote := vote.(*syncVote)
		if _, recorded := voters[vote.voter.PublicKey()]; recorded {
			continue 
		}
		voters[vote.voter.PublicKey()] = struct{}{}
		slice = append(slice, vote)
		if len(slice) == cap(slice) {
			sampler.Tick(calculateTallies(s.accounts, slice))
			voters = make(map[AccountID]struct{}, cap(votes))
			slice = slice[:0]
		}
	}
}
func ( s * SyncManager ) consolidateVotesFromPeers ( sampler * Snowball , votes <- chan Vote ) { slice := make ( [ ] Vote , 0 , cap ( votes ) ) voters := make ( map [ AccountID ] struct { } , cap ( votes ) ) for vote := range votes { vote := vote . ( * syncVote ) if _ , recorded := voters [ vote . voter . PublicKey ( ) ] ; recorded { continue } voters [ vote . voter . PublicKey ( ) ] = struct { } { } slice = append ( slice , vote ) if len ( slice ) == cap ( slice ) { sampler . Tick ( calculateTallies ( s . accounts , slice ) ) voters = make ( map [ AccountID ] struct { } , cap ( votes ) ) slice = slice [ : 0 ] } } }
Consolidate votes from our peers to figure out if our latest state if out-of-date.
Consolidate votes from our peers to figure out if our latest state if out - of - date .
// To make sure the sampling process is fair, only allow one vote per peer.