Add mechanism to get blockhash's last valid slot (#10239)

automerge
This commit is contained in:
Tyera Eulberg
2020-05-26 13:06:21 -06:00
committed by GitHub
parent 1bfc4c1489
commit 4e431bc818
8 changed files with 160 additions and 17 deletions

View File

@@ -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 {