bank: get hash and fee rate from the same source when storing accounts

This commit is contained in:
Trent Nelson 2021-11-30 23:56:27 -07:00 committed by Trent Nelson
parent 308d7d40d0
commit 91c6a10cda
1 changed files with 12 additions and 2 deletions

View File

@ -3168,6 +3168,15 @@ impl Bank {
self.blockhash_queue.read().unwrap().last_hash()
}
pub fn last_blockhash_and_lamports_per_signature(&self) -> (Hash, u64) {
let blockhash_queue = self.blockhash_queue.read().unwrap();
let last_hash = blockhash_queue.last_hash();
let last_lamports_per_signature = blockhash_queue
.get_lamports_per_signature(&last_hash)
.unwrap(); // safe so long as the BlockhashQueue is consistent
(last_hash, last_lamports_per_signature)
}
pub fn is_blockhash_valid(&self, hash: &Hash) -> bool {
let blockhash_queue = self.blockhash_queue.read().unwrap();
blockhash_queue.check_hash(hash)
@ -4164,6 +4173,7 @@ impl Bank {
self.is_delta.store(true, Relaxed);
}
let (blockhash, lamports_per_signature) = self.last_blockhash_and_lamports_per_signature();
let mut write_time = Measure::start("write_time");
self.rc.accounts.store_cached(
self.slot(),
@ -4171,8 +4181,8 @@ impl Bank {
executed_results,
loaded_txs,
&self.rent_collector,
&self.last_blockhash(),
self.get_lamports_per_signature(),
&blockhash,
lamports_per_signature,
self.rent_for_sysvars(),
self.merge_nonce_error_into_system_error(),
self.demote_program_write_locks(),