SDK: Allow RecentBlockhashes to hold the entire BlockhashQueue (#8632) (#8672)

automerge

(cherry picked from commit 9d667db634)

Co-authored-by: Grimes <39311140+solana-grimes@users.noreply.github.com>
This commit is contained in:
Michael Vines
2020-03-05 12:09:13 -07:00
committed by GitHub
parent ac3fe1da02
commit bda2acb06d
2 changed files with 16 additions and 10 deletions

View File

@@ -7,7 +7,7 @@ use crate::{
};
use std::{cmp::Ordering, collections::BinaryHeap, iter::FromIterator, ops::Deref};
const MAX_ENTRIES: usize = 32;
pub const MAX_ENTRIES: usize = 150;
declare_sysvar_id!(
"SysvarRecentB1ockHashes11111111111111111111",
@@ -107,7 +107,7 @@ impl<T: Ord> Iterator for IntoIterSorted<T> {
impl Sysvar for RecentBlockhashes {
fn size_of() -> usize {
// hard-coded so that we don't have to construct an empty
1288 // golden, update if MAX_ENTRIES changes
6008 // golden, update if MAX_ENTRIES changes
}
}
@@ -162,10 +162,16 @@ pub fn create_test_recent_blockhashes(start: usize) -> RecentBlockhashes {
#[cfg(test)]
mod tests {
use super::*;
use crate::hash::HASH_BYTES;
use crate::{clock::MAX_PROCESSING_AGE, hash::HASH_BYTES};
use rand::seq::SliceRandom;
use rand::thread_rng;
#[test]
fn test_sysvar_can_hold_all_active_blockhashes() {
// Ensure we can still hold all of the active entries in `BlockhashQueue`
assert!(MAX_PROCESSING_AGE <= MAX_ENTRIES);
}
#[test]
fn test_size_of() {
let entry = Entry::new(&Hash::default(), &FeeCalculator::default());