mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add reth db snapshot transactions | receipts commands (#5007)
Co-authored-by: Alexey Shekhirin <a.shekhirin@gmail.com>
This commit is contained in:
@ -91,7 +91,7 @@ pub use transaction::{
|
||||
IntoRecoveredTransaction, InvalidTransactionError, PooledTransactionsElement,
|
||||
PooledTransactionsElementEcRecovered, Signature, Transaction, TransactionKind, TransactionMeta,
|
||||
TransactionSigned, TransactionSignedEcRecovered, TransactionSignedNoHash, TxEip1559, TxEip2930,
|
||||
TxEip4844, TxLegacy, TxType, TxValue, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID,
|
||||
TxEip4844, TxHashOrNumber, TxLegacy, TxType, TxValue, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID,
|
||||
EIP4844_TX_TYPE_ID, LEGACY_TX_TYPE_ID,
|
||||
};
|
||||
pub use withdrawal::Withdrawal;
|
||||
|
||||
@ -6,4 +6,4 @@ mod segment;
|
||||
|
||||
pub use compression::Compression;
|
||||
pub use filters::{Filters, InclusionFilter, PerfectHashingFunction};
|
||||
pub use segment::SnapshotSegment;
|
||||
pub use segment::{SegmentHeader, SnapshotSegment};
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
use crate::{BlockNumber, TxNumber};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::ops::RangeInclusive;
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
|
||||
@ -11,3 +13,30 @@ pub enum SnapshotSegment {
|
||||
/// Snapshot segment responsible for the `Receipts` table.
|
||||
Receipts,
|
||||
}
|
||||
|
||||
/// A segment header that contains information common to all segments. Used for storage.
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct SegmentHeader {
|
||||
block_range: RangeInclusive<BlockNumber>,
|
||||
tx_range: RangeInclusive<TxNumber>,
|
||||
}
|
||||
|
||||
impl SegmentHeader {
|
||||
/// Returns [`SegmentHeader`].
|
||||
pub fn new(
|
||||
block_range: RangeInclusive<BlockNumber>,
|
||||
tx_range: RangeInclusive<TxNumber>,
|
||||
) -> Self {
|
||||
Self { block_range, tx_range }
|
||||
}
|
||||
|
||||
/// Returns the first block number of the segment.
|
||||
pub fn block_start(&self) -> BlockNumber {
|
||||
*self.block_range.start()
|
||||
}
|
||||
|
||||
/// Returns the first transaction number of the segment.
|
||||
pub fn tx_start(&self) -> TxNumber {
|
||||
*self.tx_range.start()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
compression::{TRANSACTION_COMPRESSOR, TRANSACTION_DECOMPRESSOR},
|
||||
keccak256, Address, Bytes, TxHash, B256,
|
||||
keccak256, Address, BlockHashOrNumber, Bytes, TxHash, B256,
|
||||
};
|
||||
use alloy_rlp::{
|
||||
Decodable, Encodable, Error as RlpError, Header, EMPTY_LIST_CODE, EMPTY_STRING_CODE,
|
||||
@ -1307,6 +1307,9 @@ impl IntoRecoveredTransaction for TransactionSignedEcRecovered {
|
||||
}
|
||||
}
|
||||
|
||||
/// Either a transaction hash or number.
|
||||
pub type TxHashOrNumber = BlockHashOrNumber;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{
|
||||
|
||||
Reference in New Issue
Block a user