From 7c35191322641d084c27df16bb5ee8f76d62a98e Mon Sep 17 00:00:00 2001 From: Tyera Date: Tue, 14 Feb 2023 16:32:26 -0700 Subject: [PATCH] Scope SamplePerformanceService Bank only for initial sample snapshot (#30316) * Scope Bank only for initial sample snapshot * Remove nesting --- core/src/sample_performance_service.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/core/src/sample_performance_service.rs b/core/src/sample_performance_service.rs index a82b433450..5f5b9b6655 100644 --- a/core/src/sample_performance_service.rs +++ b/core/src/sample_performance_service.rs @@ -51,18 +51,19 @@ impl SamplePerformanceService { blockstore: &Arc, exit: Arc, ) { - let (bank, highest_slot) = { + let mut snapshot = { let forks = bank_forks.read().unwrap(); - (forks.root_bank(), forks.highest_slot()) - }; + let bank = forks.root_bank(); + let highest_slot = forks.highest_slot(); - // Store the absolute transaction counts to that we can compute the - // difference between these values at points in time to figure out - // how many transactions occurred in that timespan. - let mut snapshot = SamplePerformanceSnapshot { - num_transactions: bank.transaction_count(), - num_non_vote_transactions: bank.non_vote_transaction_count_since_restart(), - highest_slot, + // Store the absolute transaction counts to that we can compute the + // difference between these values at points in time to figure out + // how many transactions occurred in that timespan. + SamplePerformanceSnapshot { + num_transactions: bank.transaction_count(), + num_non_vote_transactions: bank.non_vote_transaction_count_since_restart(), + highest_slot, + } }; let mut now = Instant::now();