mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: refactor generation of snapshots from the cli (#5464)
This commit is contained in:
@ -31,7 +31,7 @@ impl Default for Headers {
|
||||
}
|
||||
|
||||
impl Segment for Headers {
|
||||
fn segment() -> SnapshotSegment {
|
||||
fn segment(&self) -> SnapshotSegment {
|
||||
SnapshotSegment::Headers
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ impl Segment for Headers {
|
||||
let mut jar = prepare_jar::<DB, 3>(
|
||||
provider,
|
||||
directory,
|
||||
Self::segment(),
|
||||
self.segment(),
|
||||
self.config,
|
||||
range.clone(),
|
||||
range_len,
|
||||
|
||||
@ -37,7 +37,7 @@ pub trait Segment: Default {
|
||||
) -> ProviderResult<()>;
|
||||
|
||||
/// Returns this struct's [`SnapshotSegment`].
|
||||
fn segment() -> SnapshotSegment;
|
||||
fn segment(&self) -> SnapshotSegment;
|
||||
|
||||
/// Generates the dataset to train a zstd dictionary with the most recent rows (at most 1000).
|
||||
fn dataset_for_compression<DB: Database, T: Table<Key = u64>>(
|
||||
|
||||
@ -28,7 +28,7 @@ impl Default for Receipts {
|
||||
}
|
||||
|
||||
impl Segment for Receipts {
|
||||
fn segment() -> SnapshotSegment {
|
||||
fn segment(&self) -> SnapshotSegment {
|
||||
SnapshotSegment::Receipts
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ impl Segment for Receipts {
|
||||
let mut jar = prepare_jar::<DB, 1>(
|
||||
provider,
|
||||
directory,
|
||||
Self::segment(),
|
||||
self.segment(),
|
||||
self.config,
|
||||
block_range,
|
||||
tx_range_len,
|
||||
|
||||
@ -28,7 +28,7 @@ impl Default for Transactions {
|
||||
}
|
||||
|
||||
impl Segment for Transactions {
|
||||
fn segment() -> SnapshotSegment {
|
||||
fn segment(&self) -> SnapshotSegment {
|
||||
SnapshotSegment::Transactions
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ impl Segment for Transactions {
|
||||
let mut jar = prepare_jar::<DB, 1>(
|
||||
provider,
|
||||
directory,
|
||||
Self::segment(),
|
||||
self.segment(),
|
||||
self.config,
|
||||
block_range,
|
||||
tx_range_len,
|
||||
|
||||
@ -210,9 +210,10 @@ impl<DB: Database> Snapshotter<DB> {
|
||||
let temp = self.snapshots_path.join(TEMPORARY_SUBDIRECTORY);
|
||||
let provider = self.provider_factory.provider()?;
|
||||
let tx_range = provider.transaction_range_by_block_range(block_range.clone())?;
|
||||
let filename = S::segment().filename(&block_range, &tx_range);
|
||||
let segment = S::default();
|
||||
let filename = segment.segment().filename(&block_range, &tx_range);
|
||||
|
||||
S::default().snapshot::<DB>(&provider, temp.clone(), block_range)?;
|
||||
segment.snapshot::<DB>(&provider, temp.clone(), block_range)?;
|
||||
|
||||
reth_primitives::fs::rename(temp.join(&filename), self.snapshots_path.join(filename))?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user