@ -936,6 +936,15 @@ impl Bank {
|
||||
&self.fee_rate_governor
|
||||
}
|
||||
|
||||
pub fn get_blockhash_last_valid_slot(&self, blockhash: &Hash) -> Option<Slot> {
|
||||
let blockhash_queue = self.blockhash_queue.read().unwrap();
|
||||
// This calculation will need to be updated to consider epoch boundaries if BlockhashQueue
|
||||
// length is made variable by epoch
|
||||
blockhash_queue
|
||||
.get_hash_age(blockhash)
|
||||
.map(|age| self.slot + blockhash_queue.len() as u64 - age)
|
||||
}
|
||||
|
||||
pub fn confirmed_last_blockhash(&self) -> (Hash, FeeCalculator) {
|
||||
const NUM_BLOCKHASH_CONFIRMATIONS: usize = 3;
|
||||
|
||||
|
@ -58,6 +58,12 @@ impl BlockhashQueue {
|
||||
.map(|age| self.hash_height - age.hash_height <= max_age as u64)
|
||||
}
|
||||
|
||||
pub fn get_hash_age(&self, hash: &Hash) -> Option<u64> {
|
||||
self.ages
|
||||
.get(hash)
|
||||
.map(|age| self.hash_height - age.hash_height)
|
||||
}
|
||||
|
||||
/// check if hash is valid
|
||||
#[cfg(test)]
|
||||
pub fn check_hash(&self, hash: Hash) -> bool {
|
||||
@ -119,6 +125,10 @@ impl BlockhashQueue {
|
||||
.iter()
|
||||
.map(|(k, v)| recent_blockhashes::IterItem(v.hash_height, k, &v.fee_calculator))
|
||||
}
|
||||
|
||||
pub fn len(&self) -> usize {
|
||||
self.max_age
|
||||
}
|
||||
}
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
Reference in New Issue
Block a user