-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor
casper-db-utils
to make it compatible with casper-node 2.0
Signed-off-by: Alexandru Sardan <[email protected]>
- Loading branch information
Alexandru Sardan
committed
May 30, 2024
1 parent
534ee15
commit 71ac6b1
Showing
54 changed files
with
3,036 additions
and
5,205 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
pub mod db; | ||
pub mod lmdb_utils; | ||
pub mod progress; |
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,35 @@ | ||
use std::{ | ||
fmt::{Display, Formatter, Result as FormatterResult}, | ||
result::Result, | ||
}; | ||
|
||
#[derive(Deserialize)] | ||
struct LegacyApprovalsHashes { | ||
_block_hash: BlockHash, | ||
_approvals_hashes: Vec<ApprovalsHash>, | ||
_merkle_proof_approvals: TrieMerkleProof<Key, StoredValue>, | ||
} | ||
|
||
use casper_types::{global_state::TrieMerkleProof, ApprovalsHash, BlockHash, Key, StoredValue}; | ||
use serde::Deserialize; | ||
|
||
use super::{Database, DeserializationError}; | ||
|
||
pub struct ApprovalsHashesDatabase; | ||
|
||
impl Display for ApprovalsHashesDatabase { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> FormatterResult { | ||
write!(f, "approvals_hashes") | ||
} | ||
} | ||
|
||
impl Database for ApprovalsHashesDatabase { | ||
fn db_name() -> &'static str { | ||
"approvals_hashes" | ||
} | ||
|
||
fn parse_element(bytes: &[u8]) -> Result<(), DeserializationError> { | ||
let _: LegacyApprovalsHashes = bincode::deserialize(bytes)?; | ||
Ok(()) | ||
} | ||
} |
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
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,27 @@ | ||
use std::{ | ||
fmt::{Display, Formatter, Result as FormatterResult}, | ||
result::Result, | ||
}; | ||
|
||
use casper_types::{bytesrepr::FromBytes, BlockSignatures}; | ||
|
||
use super::{Database, DeserializationError}; | ||
|
||
pub struct VersionedBlockMetadataDatabase; | ||
|
||
impl Display for VersionedBlockMetadataDatabase { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> FormatterResult { | ||
write!(f, "block_metadata_v2") | ||
} | ||
} | ||
|
||
impl Database for VersionedBlockMetadataDatabase { | ||
fn db_name() -> &'static str { | ||
"block_metadata_v2" | ||
} | ||
|
||
fn parse_element(bytes: &[u8]) -> Result<(), DeserializationError> { | ||
let _: BlockSignatures = FromBytes::from_bytes(bytes)?.0; | ||
Ok(()) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,26 +1,33 @@ | ||
use casper_node::types::DeployMetadata; | ||
use casper_types::{execution::ExecutionResultV1, BlockHash}; | ||
use serde::{Deserialize, Serialize}; | ||
use std::{ | ||
collections::HashMap, | ||
fmt::{Display, Formatter, Result as FormatterResult}, | ||
result::Result, | ||
}; | ||
|
||
use super::{Database, DeserializationError}; | ||
|
||
pub struct DeployMetadataDatabase; | ||
#[derive(Clone, Default, Serialize, Deserialize, Debug, PartialEq, Eq)] | ||
struct DeployMetadataV1 { | ||
execution_results: HashMap<BlockHash, ExecutionResultV1>, | ||
} | ||
|
||
pub struct LegacyDeployMetadataDatabase; | ||
|
||
impl Display for DeployMetadataDatabase { | ||
impl Display for LegacyDeployMetadataDatabase { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> FormatterResult { | ||
write!(f, "deploy_metadata") | ||
} | ||
} | ||
|
||
impl Database for DeployMetadataDatabase { | ||
impl Database for LegacyDeployMetadataDatabase { | ||
fn db_name() -> &'static str { | ||
"deploy_metadata" | ||
} | ||
|
||
fn parse_element(bytes: &[u8]) -> Result<(), DeserializationError> { | ||
let _: DeployMetadata = bincode::deserialize(bytes)?; | ||
let _: DeployMetadataV1 = bincode::deserialize(bytes)?; | ||
Ok(()) | ||
} | ||
} |
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
Oops, something went wrong.