From 3d6fff70e072252e101bba491835bfd346821944 Mon Sep 17 00:00:00 2001 From: StephenButtolph Date: Tue, 16 Jun 2020 23:53:19 -0400 Subject: [PATCH] nits to clean up the PR --- snow/engine/avalanche/polls.go | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/snow/engine/avalanche/polls.go b/snow/engine/avalanche/polls.go index 3bf0498..ac3fe5c 100644 --- a/snow/engine/avalanche/polls.go +++ b/snow/engine/avalanche/polls.go @@ -110,30 +110,27 @@ func (p *poll) Vote(votes []ids.ID, vdr ids.ShortID) { // Finished returns true if the poll has completed, with no more required // responses func (p poll) Finished() bool { - // If I have no outstanding polls, I'm finished + // If there are no outstanding queries, the poll is finished numPending := p.polled.Len() if numPending == 0 { return true } // If there are still enough pending responses to include another vertex, - // then I can't stop polling + // then the poll must wait for more responses if numPending > p.alpha { return false } - // I ignore any vertex that has already received alpha votes. - // To safely skip DAG traversal, assume that all votes for - // vertices with less than alpha votes will be applied to a - // single shared ancestor. - // In this case, I can terminate early, iff there are not enough - // pending votes for this ancestor to receive alpha votes. + // Ignore any vertex that has already received alpha votes. To safely skip + // DAG traversal, assume that all votes for vertices with less than alpha + // votes will be applied to a single shared ancestor. In this case, the poll + // can terminate early, iff there are not enough pending votes for this + // ancestor to receive alpha votes. partialVotes := ids.BitSet(0) for _, vote := range p.votes.List() { - voters := p.votes.GetSet(vote) - if voters.Len() >= p.alpha { - continue + if voters := p.votes.GetSet(vote); voters.Len() < p.alpha { + partialVotes.Union(voters) } - partialVotes.Union(voters) } return partialVotes.Len()+numPending < p.alpha }