Snapshot optimizations (#5518)
* Limit slots_since_snapshot size, only package latest snapshot, refactor tests * Add test checking status_cache.roots == bank_forks.slots_since_snapshot after bank_forks.set_root()
This commit is contained in:
@ -45,7 +45,7 @@ use solana_sdk::{
|
||||
timing::{duration_as_ns, get_segment_from_slot, Epoch, Slot, MAX_RECENT_BLOCKHASHES},
|
||||
transaction::{Result, Transaction, TransactionError},
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::io::{BufReader, Cursor, Error as IOError, Read};
|
||||
use std::path::Path;
|
||||
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
||||
@ -124,7 +124,7 @@ impl Serialize for BankRc {
|
||||
pub struct StatusCacheRc {
|
||||
/// where all the Accounts are stored
|
||||
/// A cache of signature statuses
|
||||
status_cache: Arc<RwLock<BankStatusCache>>,
|
||||
pub status_cache: Arc<RwLock<BankStatusCache>>,
|
||||
}
|
||||
|
||||
impl StatusCacheRc {
|
||||
@ -133,6 +133,10 @@ impl StatusCacheRc {
|
||||
sc.slot_deltas(slots)
|
||||
}
|
||||
|
||||
pub fn roots(&self) -> HashSet<u64> {
|
||||
self.status_cache.read().unwrap().roots().clone()
|
||||
}
|
||||
|
||||
pub fn append(&self, slot_deltas: &[SlotDelta<Result<()>>]) {
|
||||
let mut sc = self.status_cache.write().unwrap();
|
||||
sc.append(slot_deltas);
|
||||
|
@ -124,6 +124,10 @@ impl<T: Serialize + Clone> StatusCache<T> {
|
||||
self.purge_roots();
|
||||
}
|
||||
|
||||
pub fn roots(&self) -> &HashSet<u64> {
|
||||
&self.roots
|
||||
}
|
||||
|
||||
/// Insert a new signature for a specific slot.
|
||||
pub fn insert(&mut self, transaction_blockhash: &Hash, sig: &Signature, slot: Slot, res: T) {
|
||||
let sig_index: usize;
|
||||
|
Reference in New Issue
Block a user