/** Methods that help us figure out whether or not our node is out-of-sync. */
Methods that help us figure out whether or not our node is out-of-sync.
/ ** Methods that help us figure out whether or not our node is out - of - sync . * /
func (s *SyncManager) stateOutOfSync() (bool, error) {
	samplerK := conf.GetSnowballK()
	sampler := NewSnowball()
	sampler.Prefer(&syncVote{outOfSync: false})
	votes := make(chan Vote, samplerK)
	go s.consolidateVotesFromPeers(sampler, votes)
	for { 
		converged, err := s.collectVotesFromPeers(sampler, votes, samplerK)
		if err != nil {
			return false, err
		}
		if converged {
			break
		}
		s.wait(5 * time.Millisecond)
		if s.closed() {
			return false, nil
		}
	}
	return sampler.preferred.(*syncVote).outOfSync, nil
}
func ( s * SyncManager ) stateOutOfSync ( ) ( bool , error ) { samplerK := conf . GetSnowballK ( ) sampler := NewSnowball ( ) sampler . Prefer ( & syncVote { outOfSync : false } ) votes := make ( chan Vote , samplerK ) go s . consolidateVotesFromPeers ( sampler , votes ) for { converged , err := s . collectVotesFromPeers ( sampler , votes , samplerK ) if err != nil { return false , err } if converged { break } s . wait ( 5 * time . Millisecond ) if s . closed ( ) { return false , nil } } return sampler . preferred . ( * syncVote ) . outOfSync , nil }
Methods that help us figure out whether or not our node is out-of-sync.
Methods that help us figure out whether or not our node is out - of - sync .
// Our initial belief is that we're not out-of-sync. // Run a worker to consolidate votes from our peers as to whether or not our state is out-of-sync. // Infinitely keep asking our peers if we are out-of-sync given our latest state.