mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(primitives, storage): save prune checkpoints in database (#3628)
This commit is contained in:
@ -49,7 +49,7 @@ pub trait Encode: Send + Sync + Sized + Debug {
|
||||
/// Trait that will transform the data to be read from the DB.
|
||||
pub trait Decode: Send + Sync + Sized + Debug {
|
||||
/// Decodes data coming from the database.
|
||||
fn decode<B: AsRef<[u8]>>(key: B) -> Result<Self, DatabaseError>;
|
||||
fn decode<B: AsRef<[u8]>>(value: B) -> Result<Self, DatabaseError>;
|
||||
}
|
||||
|
||||
/// Generic trait that enforces the database key to implement [`Encode`] and [`Decode`].
|
||||
|
||||
@ -37,8 +37,8 @@ use crate::{
|
||||
use reth_primitives::{
|
||||
stage::StageCheckpoint,
|
||||
trie::{BranchNodeCompact, StorageTrieEntry, StoredNibbles, StoredNibblesSubKey},
|
||||
Account, Address, BlockHash, BlockNumber, Bytecode, Header, IntegerList, Receipt, StorageEntry,
|
||||
TransactionSignedNoHash, TxHash, TxNumber, H256,
|
||||
Account, Address, BlockHash, BlockNumber, Bytecode, Header, IntegerList, PruneCheckpoint,
|
||||
PrunePart, Receipt, StorageEntry, TransactionSignedNoHash, TxHash, TxNumber, H256,
|
||||
};
|
||||
|
||||
/// Enum for the types of tables present in libmdbx.
|
||||
@ -415,6 +415,11 @@ table!(
|
||||
( SyncStageProgress ) StageId | Vec<u8>
|
||||
);
|
||||
|
||||
table!(
|
||||
/// Stores the highest pruned block number and prune mode of each prune part.
|
||||
( PruneParts ) PrunePart | PruneCheckpoint
|
||||
);
|
||||
|
||||
/// Alias Types
|
||||
|
||||
/// List with transaction numbers.
|
||||
|
||||
@ -6,7 +6,7 @@ use crate::{
|
||||
use reth_codecs::Compact;
|
||||
use reth_primitives::{
|
||||
trie::{StoredNibbles, StoredNibblesSubKey},
|
||||
Address, H256,
|
||||
Address, PrunePart, H256,
|
||||
};
|
||||
|
||||
pub mod accounts;
|
||||
@ -135,3 +135,20 @@ impl Decode for StoredNibblesSubKey {
|
||||
Ok(Self::from_compact(buf, buf.len()).0)
|
||||
}
|
||||
}
|
||||
|
||||
impl Encode for PrunePart {
|
||||
type Encoded = [u8; 1];
|
||||
|
||||
fn encode(self) -> Self::Encoded {
|
||||
let mut buf = [0u8];
|
||||
self.to_compact(&mut buf.as_mut());
|
||||
buf
|
||||
}
|
||||
}
|
||||
|
||||
impl Decode for PrunePart {
|
||||
fn decode<B: AsRef<[u8]>>(value: B) -> Result<Self, DatabaseError> {
|
||||
let buf = value.as_ref();
|
||||
Ok(Self::from_compact(buf, buf.len()).0)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user