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},
};
use solana_runtime::{
accounts_db::AccountStorageEntry, bank::MAX_SNAPSHOT_DATA_FILE_SIZE,
status_cache::SlotDelta,
accounts_db::AccountStorageEntry, bank::BankSlotDelta, bank::MAX_SNAPSHOT_DATA_FILE_SIZE,
};
use solana_sdk::transaction;
use std::{
fs::{self, remove_dir_all, OpenOptions},
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
// This is needed since the status_cache is added by the packager and is not collected from
// 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(
&snapshots_dir.join(SNAPSHOT_STATUS_CACHE_FILE_NAME),
MAX_SNAPSHOT_DATA_FILE_SIZE,

View File

@ -14,15 +14,15 @@ mod tests {
snapshot_utils,
};
use solana_runtime::{
bank::Bank,
status_cache::{SlotDelta, MAX_CACHE_ENTRIES},
bank::{Bank, BankSlotDelta},
status_cache::MAX_CACHE_ENTRIES,
};
use solana_sdk::{
clock::Slot,
hash::hashv,
pubkey::Pubkey,
signature::{Keypair, KeypairUtil},
system_transaction, transaction,
system_transaction,
};
use std::{fs, path::PathBuf, sync::atomic::AtomicBool, sync::mpsc::channel, sync::Arc};
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
// This is needed since the status_cache is added by the packager and is not collected from
// 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(
&saved_snapshots_dir
.path()

View File

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

View File

@ -4,12 +4,10 @@ use bzip2::bufread::BzDecoder;
use fs_extra::dir::CopyOptions;
use log::*;
use solana_measure::measure::Measure;
use solana_runtime::{
bank::{self, deserialize_from_snapshot, Bank, MAX_SNAPSHOT_DATA_FILE_SIZE},
status_cache::SlotDelta,
use solana_runtime::bank::{
self, deserialize_from_snapshot, Bank, BankSlotDelta, MAX_SNAPSHOT_DATA_FILE_SIZE,
};
use solana_sdk::transaction::Result as TransactionResult;
use solana_sdk::{clock::Slot, transaction};
use solana_sdk::clock::Slot;
use std::{
cmp::Ordering,
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(
slot: Slot,
slot_deltas: &[SlotDelta<TransactionResult<()>>],
slot_deltas: &[BankSlotDelta],
snapshot_links: &TempDir,
) -> Result<()> {
// the status cache is stored as snapshot_path/status_cache
@ -549,8 +547,7 @@ where
MAX_SNAPSHOT_DATA_FILE_SIZE,
|stream| {
// Rebuild status cache
let slot_deltas: Vec<SlotDelta<transaction::Result<()>>> =
deserialize_from_snapshot(stream)?;
let slot_deltas: Vec<BankSlotDelta> = deserialize_from_snapshot(stream)?;
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;
type BankStatusCache = StatusCache<Result<()>>;
pub type BankSlotDelta = SlotDelta<Result<()>>;
type TransactionAccountRefCells = Vec<Rc<RefCell<Account>>>;
type TransactionLoaderRefCells = Vec<Vec<(Pubkey, RefCell<Account>)>>;
@ -143,7 +144,7 @@ pub struct 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();
sc.slot_deltas(slots)
}
@ -159,7 +160,7 @@ impl StatusCacheRc {
.collect()
}
pub fn append(&self, slot_deltas: &[SlotDelta<Result<()>>]) {
pub fn append(&self, slot_deltas: &[BankSlotDelta]) {
let mut sc = self.status_cache.write().unwrap();
sc.append(slot_deltas);
}