From a0d940acf0f7aee33332be1dc5430f868729b92a Mon Sep 17 00:00:00 2001 From: Anatoly Yakovenko Date: Tue, 19 Mar 2019 16:54:58 -0700 Subject: [PATCH] allow empty ancestors --- core/src/locktower.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/locktower.rs b/core/src/locktower.rs index 31df4474ce..880cef59ff 100644 --- a/core/src/locktower.rs +++ b/core/src/locktower.rs @@ -125,6 +125,7 @@ impl Locktower { confirmation_count: MAX_LOCKOUT_HISTORY as u32, slot: root, }; + trace!("ROOT: {}", vote.slot); Self::update_ancestor_lockouts(&mut stake_lockouts, &vote, ancestors); } } @@ -228,7 +229,7 @@ impl Locktower { ancestors: &HashMap>, ) { let mut slot_with_ancestors = vec![vote.slot]; - slot_with_ancestors.extend(&ancestors[&vote.slot]); + slot_with_ancestors.extend(ancestors.get(&vote.slot).unwrap_or(&HashSet::new())); for slot in slot_with_ancestors { let entry = &mut stake_lockouts.entry(slot).or_default(); entry.lockout += vote.lockout(); @@ -244,7 +245,7 @@ impl Locktower { ancestors: &HashMap>, ) { let mut slot_with_ancestors = vec![slot]; - slot_with_ancestors.extend(&ancestors[&slot]); + slot_with_ancestors.extend(ancestors.get(&slot).unwrap_or(&HashSet::new())); for slot in slot_with_ancestors { let entry = &mut stake_lockouts.entry(slot).or_default(); entry.stake += lamports;