From 0c0b65e9ab7f4b8a6ef4283a40a179813607e1e2 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 5 Apr 2021 06:54:23 +0000 Subject: [PATCH] Only get Blockstore::last_root once (#16362) (#16365) (cherry picked from commit b8b677726200d54e76c787825c8f4d7a3af083d9) Co-authored-by: Tyera Eulberg --- ledger/src/blockstore.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ledger/src/blockstore.rs b/ledger/src/blockstore.rs index d709af3754..f2473c0365 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -2053,9 +2053,10 @@ impl Blockstore { "blockstore-rpc-api", ("method", "get_complete_transaction".to_string(), String) ); + let last_root = self.last_root(); let confirmed_unrooted_slots: Vec<_> = AncestorIterator::new_inclusive(highest_confirmed_slot, self) - .take_while(|&slot| slot > self.last_root()) + .take_while(|&slot| slot > last_root) .collect(); self.get_transaction_with_status(signature, &confirmed_unrooted_slots) } @@ -2213,8 +2214,9 @@ impl Blockstore { String ) ); + let last_root = self.last_root(); let confirmed_unrooted_slots: Vec<_> = AncestorIterator::new_inclusive(highest_slot, self) - .take_while(|&slot| slot > self.last_root()) + .take_while(|&slot| slot > last_root) .collect(); // Figure the `slot` to start listing signatures at, based on the ledger location of the