Skip to content

Commit

Permalink
AcctIdx: define type for serialized AppendVecId (solana-labs#21938)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwashington authored Dec 16, 2021
1 parent 18417e4 commit e97da0e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions runtime/src/serde_snapshot/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,23 @@ use {

type AccountsDbFields = super::AccountsDbFields<SerializableAccountStorageEntry>;

/// the serialized type is fixed as usize
pub type AppendVecIdSerialized = usize;

// Serializable version of AccountStorageEntry for snapshot format
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
pub(super) struct SerializableAccountStorageEntry {
id: AppendVecId,
id: AppendVecIdSerialized,
accounts_current_len: usize,
}

pub trait SerializableStorage {
fn id(&self) -> AppendVecId;
fn id(&self) -> AppendVecIdSerialized;
fn current_len(&self) -> usize;
}

impl SerializableStorage for SerializableAccountStorageEntry {
fn id(&self) -> AppendVecId {
fn id(&self) -> AppendVecIdSerialized {
self.id
}
fn current_len(&self) -> usize {
Expand All @@ -36,7 +39,7 @@ impl solana_frozen_abi::abi_example::IgnoreAsHelper for SerializableAccountStora
impl From<&AccountStorageEntry> for SerializableAccountStorageEntry {
fn from(rhs: &AccountStorageEntry) -> Self {
Self {
id: rhs.append_vec_id(),
id: rhs.append_vec_id() as AppendVecIdSerialized,
accounts_current_len: rhs.accounts.len(),
}
}
Expand Down

0 comments on commit e97da0e

Please sign in to comment.