Skip to content

Commit

Permalink
bank: get hash and fee rate from the same source when storing accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
t-nelson committed Dec 1, 2021
1 parent 308d7d4 commit 91c6a10
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -4164,15 +4173,16 @@ 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(),
sanitized_txs,
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(),
Expand Down

0 comments on commit 91c6a10

Please sign in to comment.