AcctIdx: define type for serialized AppendVecId (#21938)
This commit is contained in:
parent
18417e410e
commit
e97da0ea15
|
@ -9,20 +9,23 @@ use {
|
||||||
|
|
||||||
type AccountsDbFields = super::AccountsDbFields<SerializableAccountStorageEntry>;
|
type AccountsDbFields = super::AccountsDbFields<SerializableAccountStorageEntry>;
|
||||||
|
|
||||||
|
/// the serialized type is fixed as usize
|
||||||
|
pub type AppendVecIdSerialized = usize;
|
||||||
|
|
||||||
// Serializable version of AccountStorageEntry for snapshot format
|
// Serializable version of AccountStorageEntry for snapshot format
|
||||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
||||||
pub(super) struct SerializableAccountStorageEntry {
|
pub(super) struct SerializableAccountStorageEntry {
|
||||||
id: AppendVecId,
|
id: AppendVecIdSerialized,
|
||||||
accounts_current_len: usize,
|
accounts_current_len: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait SerializableStorage {
|
pub trait SerializableStorage {
|
||||||
fn id(&self) -> AppendVecId;
|
fn id(&self) -> AppendVecIdSerialized;
|
||||||
fn current_len(&self) -> usize;
|
fn current_len(&self) -> usize;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SerializableStorage for SerializableAccountStorageEntry {
|
impl SerializableStorage for SerializableAccountStorageEntry {
|
||||||
fn id(&self) -> AppendVecId {
|
fn id(&self) -> AppendVecIdSerialized {
|
||||||
self.id
|
self.id
|
||||||
}
|
}
|
||||||
fn current_len(&self) -> usize {
|
fn current_len(&self) -> usize {
|
||||||
|
@ -36,7 +39,7 @@ impl solana_frozen_abi::abi_example::IgnoreAsHelper for SerializableAccountStora
|
||||||
impl From<&AccountStorageEntry> for SerializableAccountStorageEntry {
|
impl From<&AccountStorageEntry> for SerializableAccountStorageEntry {
|
||||||
fn from(rhs: &AccountStorageEntry) -> Self {
|
fn from(rhs: &AccountStorageEntry) -> Self {
|
||||||
Self {
|
Self {
|
||||||
id: rhs.append_vec_id(),
|
id: rhs.append_vec_id() as AppendVecIdSerialized,
|
||||||
accounts_current_len: rhs.accounts.len(),
|
accounts_current_len: rhs.accounts.len(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue