Adds serde_snapshot::types module (#30501)
This commit is contained in:
parent
31573beb2d
commit
ffe2d309b2
|
@ -7,7 +7,7 @@ use {
|
||||||
AtomicAppendVecId, BankHashStats, IndexGenerationInfo,
|
AtomicAppendVecId, BankHashStats, IndexGenerationInfo,
|
||||||
},
|
},
|
||||||
accounts_file::AccountsFile,
|
accounts_file::AccountsFile,
|
||||||
accounts_hash::{AccountsDeltaHash, AccountsHash},
|
accounts_hash::AccountsHash,
|
||||||
accounts_index::AccountSecondaryIndexes,
|
accounts_index::AccountSecondaryIndexes,
|
||||||
accounts_update_notifier_interface::AccountsUpdateNotifier,
|
accounts_update_notifier_interface::AccountsUpdateNotifier,
|
||||||
append_vec::AppendVec,
|
append_vec::AppendVec,
|
||||||
|
@ -54,12 +54,16 @@ use {
|
||||||
mod newer;
|
mod newer;
|
||||||
mod storage;
|
mod storage;
|
||||||
mod tests;
|
mod tests;
|
||||||
|
mod types;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
pub(crate) use storage::SerializedAppendVecId;
|
|
||||||
// a number of test cases in accounts_db use this
|
// a number of test cases in accounts_db use this
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub(crate) use tests::reconstruct_accounts_db_via_serialization;
|
pub(crate) use tests::reconstruct_accounts_db_via_serialization;
|
||||||
|
pub(crate) use {
|
||||||
|
storage::SerializedAppendVecId,
|
||||||
|
types::{SerdeAccountsDeltaHash, SerdeAccountsHash},
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Copy, Clone, Eq, PartialEq)]
|
#[derive(Copy, Clone, Eq, PartialEq)]
|
||||||
pub(crate) enum SerdeStyle {
|
pub(crate) enum SerdeStyle {
|
||||||
|
@ -89,35 +93,6 @@ struct BankHashInfo {
|
||||||
stats: BankHashStats,
|
stats: BankHashStats,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Snapshot serde-safe accounts delta hash
|
|
||||||
#[derive(Clone, Default, Debug, Serialize, Deserialize, PartialEq, Eq, AbiExample)]
|
|
||||||
pub struct SerdeAccountsDeltaHash(pub Hash);
|
|
||||||
|
|
||||||
impl From<SerdeAccountsDeltaHash> for AccountsDeltaHash {
|
|
||||||
fn from(accounts_delta_hash: SerdeAccountsDeltaHash) -> Self {
|
|
||||||
Self(accounts_delta_hash.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl From<AccountsDeltaHash> for SerdeAccountsDeltaHash {
|
|
||||||
fn from(accounts_delta_hash: AccountsDeltaHash) -> Self {
|
|
||||||
Self(accounts_delta_hash.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Snapshot serde-safe accounts hash
|
|
||||||
#[derive(Clone, Default, Debug, Serialize, Deserialize, PartialEq, Eq, AbiExample)]
|
|
||||||
pub struct SerdeAccountsHash(pub Hash);
|
|
||||||
impl From<SerdeAccountsHash> for AccountsHash {
|
|
||||||
fn from(accounts_hash: SerdeAccountsHash) -> Self {
|
|
||||||
Self(accounts_hash.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl From<AccountsHash> for SerdeAccountsHash {
|
|
||||||
fn from(accounts_hash: AccountsHash) -> Self {
|
|
||||||
Self(accounts_hash.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Helper type to wrap BufReader streams when deserializing and reconstructing from either just a
|
/// Helper type to wrap BufReader streams when deserializing and reconstructing from either just a
|
||||||
/// full snapshot, or both a full and incremental snapshot
|
/// full snapshot, or both a full and incremental snapshot
|
||||||
pub struct SnapshotStreams<'a, R> {
|
pub struct SnapshotStreams<'a, R> {
|
||||||
|
|
|
@ -719,7 +719,7 @@ mod test_bank_serialize {
|
||||||
|
|
||||||
// This some what long test harness is required to freeze the ABI of
|
// This some what long test harness is required to freeze the ABI of
|
||||||
// Bank's serialization due to versioned nature
|
// Bank's serialization due to versioned nature
|
||||||
#[frozen_abi(digest = "FeRj6jpfB3n6FvX2edAhdwYhnBkYZgsqHufd7weFWTfx")]
|
#[frozen_abi(digest = "2TmCWJdi5zt6Y46PiNcfStrmW8ogqKut2ttRahD3SzMG")]
|
||||||
#[derive(Serialize, AbiExample)]
|
#[derive(Serialize, AbiExample)]
|
||||||
pub struct BankAbiTestWrapperNewer {
|
pub struct BankAbiTestWrapperNewer {
|
||||||
#[serde(serialize_with = "wrapper_newer")]
|
#[serde(serialize_with = "wrapper_newer")]
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
//! Types used by snapshots for safe serialization/deserialization
|
||||||
|
use {
|
||||||
|
crate::accounts_hash::{AccountsDeltaHash, AccountsHash, IncrementalAccountsHash},
|
||||||
|
serde::{Deserialize, Serialize},
|
||||||
|
solana_sdk::hash::Hash,
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Snapshot serde-safe accounts delta hash
|
||||||
|
#[derive(Clone, Default, Debug, Serialize, Deserialize, PartialEq, Eq, AbiExample)]
|
||||||
|
pub struct SerdeAccountsDeltaHash(pub Hash);
|
||||||
|
|
||||||
|
impl From<SerdeAccountsDeltaHash> for AccountsDeltaHash {
|
||||||
|
fn from(accounts_delta_hash: SerdeAccountsDeltaHash) -> Self {
|
||||||
|
Self(accounts_delta_hash.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl From<AccountsDeltaHash> for SerdeAccountsDeltaHash {
|
||||||
|
fn from(accounts_delta_hash: AccountsDeltaHash) -> Self {
|
||||||
|
Self(accounts_delta_hash.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Snapshot serde-safe accounts hash
|
||||||
|
#[derive(Clone, Default, Debug, Serialize, Deserialize, PartialEq, Eq, AbiExample)]
|
||||||
|
pub struct SerdeAccountsHash(pub Hash);
|
||||||
|
|
||||||
|
impl From<SerdeAccountsHash> for AccountsHash {
|
||||||
|
fn from(accounts_hash: SerdeAccountsHash) -> Self {
|
||||||
|
Self(accounts_hash.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl From<AccountsHash> for SerdeAccountsHash {
|
||||||
|
fn from(accounts_hash: AccountsHash) -> Self {
|
||||||
|
Self(accounts_hash.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Snapshot serde-safe incremental accounts hash
|
||||||
|
#[derive(Clone, Default, Debug, Serialize, Deserialize, PartialEq, Eq, AbiExample)]
|
||||||
|
pub struct SerdeIncrementalAccountsHash(pub Hash);
|
||||||
|
|
||||||
|
impl From<SerdeIncrementalAccountsHash> for IncrementalAccountsHash {
|
||||||
|
fn from(incremental_accounts_hash: SerdeIncrementalAccountsHash) -> Self {
|
||||||
|
Self(incremental_accounts_hash.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl From<IncrementalAccountsHash> for SerdeIncrementalAccountsHash {
|
||||||
|
fn from(incremental_accounts_hash: IncrementalAccountsHash) -> Self {
|
||||||
|
Self(incremental_accounts_hash.0)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue