mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-09 11:25:55 +00:00
Correct all fork choice rules for children with no votes.
This commit is contained in:
@@ -210,6 +210,7 @@ impl<T: ClientDB + Sized> ForkChoice for SlowLMDGhost<T> {
|
||||
trace!("Children found: {:?}", children);
|
||||
|
||||
let mut head_vote_count = 0;
|
||||
head_hash = children[0];
|
||||
for child_hash in children {
|
||||
let vote_count = self.get_vote_count(&latest_votes, &child_hash)?;
|
||||
trace!("Vote count for child: {} is: {}", child_hash, vote_count);
|
||||
@@ -218,6 +219,12 @@ impl<T: ClientDB + Sized> ForkChoice for SlowLMDGhost<T> {
|
||||
head_hash = *child_hash;
|
||||
head_vote_count = vote_count;
|
||||
}
|
||||
// resolve ties - choose smaller hash
|
||||
else if vote_count == head_vote_count {
|
||||
if *child_hash < head_hash {
|
||||
head_hash = *child_hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(head_hash)
|
||||
|
||||
Reference in New Issue
Block a user