Skip to content

Commit

Permalink
consensus: fix typo + remove duplicate code (ava-labs#1513)
Browse files Browse the repository at this point in the history
  • Loading branch information
gyuho authored May 27, 2022
1 parent ff31cdc commit abc242c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions snow/consensus/snowball/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,13 @@ func (u *unaryNode) RecordPoll(votes ids.Bag, reset bool) node {
// u.commonPrefix and u.child.DecidedPrefix() would always result in
// the same set being returned.

// If I'm now decided, return my child
newChild := u.child.RecordPoll(votes, u.shouldReset)
if u.Finalized() {
return u.child.RecordPoll(votes, u.shouldReset)
// If I'm now decided, return my child
return newChild
}
u.child = u.child.RecordPoll(votes, u.shouldReset)
u.child = newChild

// The child's preference may have changed
u.preference = u.child.Preference()
}
Expand Down Expand Up @@ -519,12 +521,12 @@ func (b *binaryNode) RecordPoll(votes ids.Bag, reset bool) node {
filteredVotes := prunedVotes.Filter(
b.bit+1, child.DecidedPrefix(), b.preferences[bit])

newChild := child.RecordPoll(filteredVotes, b.shouldReset[bit])
if b.snowball.Finalized() {
// If we are decided here, that means we must have decided due
// to this poll. Therefore, we must have decided on bit.
return child.RecordPoll(filteredVotes, b.shouldReset[bit])
return newChild
}
newChild := child.RecordPoll(filteredVotes, b.shouldReset[bit])
b.children[bit] = newChild
b.preferences[bit] = newChild.Preference()
}
Expand Down
2 changes: 1 addition & 1 deletion snow/consensus/snowman/snowman_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type snowmanBlock struct {
// less than Alpha votes
shouldFalter bool

// sb is the snowball instance used to decided which child is the canonical
// sb is the snowball instance used to decide which child is the canonical
// child of this block. If this node has not had a child issued under it,
// this value will be nil
sb snowball.Consensus
Expand Down

0 comments on commit abc242c

Please sign in to comment.