forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Supports deserializing accounts lt hash in snapshots (#2994)
- Loading branch information
1 parent
cc141d1
commit 690fad0
Showing
6 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use {solana_accounts_db::accounts_hash::AccountsLtHash, solana_lattice_hash::lt_hash::LtHash}; | ||
|
||
/// Snapshot serde-safe AccountsLtHash | ||
#[cfg_attr(feature = "frozen-abi", derive(AbiExample))] | ||
#[serde_with::serde_as] | ||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)] | ||
pub struct SerdeAccountsLtHash( | ||
// serde only has array support up to 32 elements; anything larger needs to be handled manually | ||
// see https://github.com/serde-rs/serde/issues/1937 for more information | ||
#[serde_as(as = "[_; LtHash::NUM_ELEMENTS]")] pub [u16; LtHash::NUM_ELEMENTS], | ||
); | ||
|
||
impl From<SerdeAccountsLtHash> for AccountsLtHash { | ||
fn from(accounts_lt_hash: SerdeAccountsLtHash) -> Self { | ||
Self(LtHash(accounts_lt_hash.0)) | ||
} | ||
} | ||
impl From<AccountsLtHash> for SerdeAccountsLtHash { | ||
fn from(accounts_lt_hash: AccountsLtHash) -> Self { | ||
Self(accounts_lt_hash.0 .0) | ||
} | ||
} |