From a2966cb9c14fc935f5592128a3bbc18ceedb2658 Mon Sep 17 00:00:00 2001 From: Cryptoforge Date: Thu, 4 Mar 2021 16:54:11 -0800 Subject: [PATCH] update pop blocks --- lib/src/lightwallet.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/src/lightwallet.rs b/lib/src/lightwallet.rs index 912cd86..fc45261 100644 --- a/lib/src/lightwallet.rs +++ b/lib/src/lightwallet.rs @@ -1478,10 +1478,26 @@ impl LightWallet { { let mut blks = self.blocks.write().unwrap(); - while blks.last().unwrap().height >= at_height { - blks.pop(); - num_invalidated += 1; + let mut checking = true; + + while checking { + + if blks.last().is_none() { + return num_invalidated as u64; + } + + if blks.last().unwrap().height >= at_height { + blks.pop(); + num_invalidated += 1; + } else { + checking = false; + } } + + // while blks.last().unwrap().height >= at_height { + // blks.pop(); + // num_invalidated += 1; + // } } // Next, remove entire transactions