Just define BnakSlotDelta type alias (#8186)

automerge
This commit is contained in:
Ryo Onodera 2020-02-10 20:11:37 +09:00 committed by GitHub
parent 1412ee1ca6
commit 485806c488
5 changed files with 18 additions and 22 deletions

View File

@ -59,10 +59,8 @@ mod tests {
snapshot_utils::{self, SNAPSHOT_STATUS_CACHE_FILE_NAME}, snapshot_utils::{self, SNAPSHOT_STATUS_CACHE_FILE_NAME},
}; };
use solana_runtime::{ use solana_runtime::{
accounts_db::AccountStorageEntry, bank::MAX_SNAPSHOT_DATA_FILE_SIZE, accounts_db::AccountStorageEntry, bank::BankSlotDelta, bank::MAX_SNAPSHOT_DATA_FILE_SIZE,
status_cache::SlotDelta,
}; };
use solana_sdk::transaction;
use std::{ use std::{
fs::{self, remove_dir_all, OpenOptions}, fs::{self, remove_dir_all, OpenOptions},
io::Write, io::Write,
@ -149,7 +147,7 @@ mod tests {
// before we compare, stick an empty status_cache in this dir so that the package comparision works // before we compare, stick an empty status_cache in this dir so that the package comparision works
// This is needed since the status_cache is added by the packager and is not collected from // This is needed since the status_cache is added by the packager and is not collected from
// the source dir for snapshots // the source dir for snapshots
let dummy_slot_deltas: Vec<SlotDelta<transaction::Result<()>>> = vec![]; let dummy_slot_deltas: Vec<BankSlotDelta> = vec![];
snapshot_utils::serialize_snapshot_data_file( snapshot_utils::serialize_snapshot_data_file(
&snapshots_dir.join(SNAPSHOT_STATUS_CACHE_FILE_NAME), &snapshots_dir.join(SNAPSHOT_STATUS_CACHE_FILE_NAME),
MAX_SNAPSHOT_DATA_FILE_SIZE, MAX_SNAPSHOT_DATA_FILE_SIZE,

View File

@ -14,15 +14,15 @@ mod tests {
snapshot_utils, snapshot_utils,
}; };
use solana_runtime::{ use solana_runtime::{
bank::Bank, bank::{Bank, BankSlotDelta},
status_cache::{SlotDelta, MAX_CACHE_ENTRIES}, status_cache::MAX_CACHE_ENTRIES,
}; };
use solana_sdk::{ use solana_sdk::{
clock::Slot, clock::Slot,
hash::hashv, hash::hashv,
pubkey::Pubkey, pubkey::Pubkey,
signature::{Keypair, KeypairUtil}, signature::{Keypair, KeypairUtil},
system_transaction, transaction, system_transaction,
}; };
use std::{fs, path::PathBuf, sync::atomic::AtomicBool, sync::mpsc::channel, sync::Arc}; use std::{fs, path::PathBuf, sync::atomic::AtomicBool, sync::mpsc::channel, sync::Arc};
use tempfile::TempDir; use tempfile::TempDir;
@ -312,7 +312,7 @@ mod tests {
// before we compare, stick an empty status_cache in this dir so that the package comparision works // before we compare, stick an empty status_cache in this dir so that the package comparision works
// This is needed since the status_cache is added by the packager and is not collected from // This is needed since the status_cache is added by the packager and is not collected from
// the source dir for snapshots // the source dir for snapshots
let dummy_slot_deltas: Vec<SlotDelta<transaction::Result<()>>> = vec![]; let dummy_slot_deltas: Vec<BankSlotDelta> = vec![];
snapshot_utils::serialize_snapshot_data_file( snapshot_utils::serialize_snapshot_data_file(
&saved_snapshots_dir &saved_snapshots_dir
.path() .path()

View File

@ -1,6 +1,6 @@
use solana_runtime::accounts_db::AccountStorageEntry; use solana_runtime::accounts_db::AccountStorageEntry;
use solana_runtime::status_cache::SlotDelta; use solana_runtime::bank::BankSlotDelta;
use solana_sdk::{clock::Slot, transaction}; use solana_sdk::clock::Slot;
use std::path::PathBuf; use std::path::PathBuf;
use std::sync::mpsc::{Receiver, SendError, Sender}; use std::sync::mpsc::{Receiver, SendError, Sender};
use std::sync::Arc; use std::sync::Arc;
@ -13,7 +13,7 @@ pub type SnapshotPackageSendError = SendError<SnapshotPackage>;
#[derive(Debug)] #[derive(Debug)]
pub struct SnapshotPackage { pub struct SnapshotPackage {
pub root: Slot, pub root: Slot,
pub slot_deltas: Vec<SlotDelta<transaction::Result<()>>>, pub slot_deltas: Vec<BankSlotDelta>,
pub snapshot_links: TempDir, pub snapshot_links: TempDir,
pub storage_entries: Vec<Arc<AccountStorageEntry>>, pub storage_entries: Vec<Arc<AccountStorageEntry>>,
pub tar_output_file: PathBuf, pub tar_output_file: PathBuf,
@ -22,7 +22,7 @@ pub struct SnapshotPackage {
impl SnapshotPackage { impl SnapshotPackage {
pub fn new( pub fn new(
root: Slot, root: Slot,
slot_deltas: Vec<SlotDelta<transaction::Result<()>>>, slot_deltas: Vec<BankSlotDelta>,
snapshot_links: TempDir, snapshot_links: TempDir,
storage_entries: Vec<Arc<AccountStorageEntry>>, storage_entries: Vec<Arc<AccountStorageEntry>>,
tar_output_file: PathBuf, tar_output_file: PathBuf,

View File

@ -4,12 +4,10 @@ use bzip2::bufread::BzDecoder;
use fs_extra::dir::CopyOptions; use fs_extra::dir::CopyOptions;
use log::*; use log::*;
use solana_measure::measure::Measure; use solana_measure::measure::Measure;
use solana_runtime::{ use solana_runtime::bank::{
bank::{self, deserialize_from_snapshot, Bank, MAX_SNAPSHOT_DATA_FILE_SIZE}, self, deserialize_from_snapshot, Bank, BankSlotDelta, MAX_SNAPSHOT_DATA_FILE_SIZE,
status_cache::SlotDelta,
}; };
use solana_sdk::transaction::Result as TransactionResult; use solana_sdk::clock::Slot;
use solana_sdk::{clock::Slot, transaction};
use std::{ use std::{
cmp::Ordering, cmp::Ordering,
fs::{self, File}, fs::{self, File},
@ -362,7 +360,7 @@ pub fn add_snapshot<P: AsRef<Path>>(snapshot_path: P, bank: &Bank) -> Result<Slo
pub fn serialize_status_cache( pub fn serialize_status_cache(
slot: Slot, slot: Slot,
slot_deltas: &[SlotDelta<TransactionResult<()>>], slot_deltas: &[BankSlotDelta],
snapshot_links: &TempDir, snapshot_links: &TempDir,
) -> Result<()> { ) -> Result<()> {
// the status cache is stored as snapshot_path/status_cache // the status cache is stored as snapshot_path/status_cache
@ -549,8 +547,7 @@ where
MAX_SNAPSHOT_DATA_FILE_SIZE, MAX_SNAPSHOT_DATA_FILE_SIZE,
|stream| { |stream| {
// Rebuild status cache // Rebuild status cache
let slot_deltas: Vec<SlotDelta<transaction::Result<()>>> = let slot_deltas: Vec<BankSlotDelta> = deserialize_from_snapshot(stream)?;
deserialize_from_snapshot(stream)?;
Ok(slot_deltas) Ok(slot_deltas)
}, },

View File

@ -67,6 +67,7 @@ pub const MAX_SNAPSHOT_DATA_FILE_SIZE: u64 = 32 * 1024 * 1024 * 1024; // 32 GiB
pub const MAX_LEADER_SCHEDULE_STAKES: Epoch = 5; pub const MAX_LEADER_SCHEDULE_STAKES: Epoch = 5;
type BankStatusCache = StatusCache<Result<()>>; type BankStatusCache = StatusCache<Result<()>>;
pub type BankSlotDelta = SlotDelta<Result<()>>;
type TransactionAccountRefCells = Vec<Rc<RefCell<Account>>>; type TransactionAccountRefCells = Vec<Rc<RefCell<Account>>>;
type TransactionLoaderRefCells = Vec<Vec<(Pubkey, RefCell<Account>)>>; type TransactionLoaderRefCells = Vec<Vec<(Pubkey, RefCell<Account>)>>;
@ -143,7 +144,7 @@ pub struct StatusCacheRc {
} }
impl StatusCacheRc { impl StatusCacheRc {
pub fn slot_deltas(&self, slots: &[Slot]) -> Vec<SlotDelta<Result<()>>> { pub fn slot_deltas(&self, slots: &[Slot]) -> Vec<BankSlotDelta> {
let sc = self.status_cache.read().unwrap(); let sc = self.status_cache.read().unwrap();
sc.slot_deltas(slots) sc.slot_deltas(slots)
} }
@ -159,7 +160,7 @@ impl StatusCacheRc {
.collect() .collect()
} }
pub fn append(&self, slot_deltas: &[SlotDelta<Result<()>>]) { pub fn append(&self, slot_deltas: &[BankSlotDelta]) {
let mut sc = self.status_cache.write().unwrap(); let mut sc = self.status_cache.write().unwrap();
sc.append(slot_deltas); sc.append(slot_deltas);
} }