mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-02-19 03:04:27 -05:00
fix(cli): allow no PHF or compression in snapshots (#5765)
This commit is contained in:
@@ -26,7 +26,7 @@ impl Command {
|
||||
chain: Arc<ChainSpec>,
|
||||
compression: Compression,
|
||||
inclusion_filter: InclusionFilter,
|
||||
phf: PerfectHashingFunction,
|
||||
phf: Option<PerfectHashingFunction>,
|
||||
) -> eyre::Result<()> {
|
||||
let factory = ProviderFactory::new(open_db_read_only(db_path, log_level)?, chain.clone());
|
||||
let provider = factory.provider()?;
|
||||
@@ -34,7 +34,7 @@ impl Command {
|
||||
let block_range =
|
||||
self.block_ranges(tip).first().expect("has been generated before").clone();
|
||||
|
||||
let filters = if self.with_filters {
|
||||
let filters = if let Some(phf) = self.with_filters.then_some(phf).flatten() {
|
||||
Filters::WithFilters(inclusion_filter, phf)
|
||||
} else {
|
||||
Filters::WithoutFilters
|
||||
|
||||
@@ -59,7 +59,7 @@ pub struct Command {
|
||||
only_bench: bool,
|
||||
|
||||
/// Compression algorithms to use.
|
||||
#[arg(long, short, value_delimiter = ',', default_value = "lz4")]
|
||||
#[arg(long, short, value_delimiter = ',', default_value = "uncompressed")]
|
||||
compression: Vec<Compression>,
|
||||
|
||||
/// Flag to enable inclusion list filters and PHFs.
|
||||
@@ -79,11 +79,14 @@ impl Command {
|
||||
log_level: Option<LogLevel>,
|
||||
chain: Arc<ChainSpec>,
|
||||
) -> eyre::Result<()> {
|
||||
let all_combinations = self
|
||||
.segments
|
||||
.iter()
|
||||
.cartesian_product(self.compression.iter())
|
||||
.cartesian_product(self.phf.iter());
|
||||
let all_combinations =
|
||||
self.segments.iter().cartesian_product(self.compression.iter()).cartesian_product(
|
||||
if self.phf.is_empty() {
|
||||
vec![None]
|
||||
} else {
|
||||
self.phf.iter().copied().map(Some).collect::<Vec<_>>()
|
||||
},
|
||||
);
|
||||
|
||||
{
|
||||
let db = open_db_read_only(db_path, None)?;
|
||||
@@ -91,8 +94,8 @@ impl Command {
|
||||
|
||||
if !self.only_bench {
|
||||
for ((mode, compression), phf) in all_combinations.clone() {
|
||||
let filters = if self.with_filters {
|
||||
Filters::WithFilters(InclusionFilter::Cuckoo, *phf)
|
||||
let filters = if let Some(phf) = self.with_filters.then_some(phf).flatten() {
|
||||
Filters::WithFilters(InclusionFilter::Cuckoo, phf)
|
||||
} else {
|
||||
Filters::WithoutFilters
|
||||
};
|
||||
@@ -124,7 +127,7 @@ impl Command {
|
||||
chain.clone(),
|
||||
*compression,
|
||||
InclusionFilter::Cuckoo,
|
||||
*phf,
|
||||
phf,
|
||||
)?,
|
||||
SnapshotSegment::Transactions => self.bench_transactions_snapshot(
|
||||
db_path,
|
||||
@@ -132,7 +135,7 @@ impl Command {
|
||||
chain.clone(),
|
||||
*compression,
|
||||
InclusionFilter::Cuckoo,
|
||||
*phf,
|
||||
phf,
|
||||
)?,
|
||||
SnapshotSegment::Receipts => self.bench_receipts_snapshot(
|
||||
db_path,
|
||||
@@ -140,7 +143,7 @@ impl Command {
|
||||
chain.clone(),
|
||||
*compression,
|
||||
InclusionFilter::Cuckoo,
|
||||
*phf,
|
||||
phf,
|
||||
)?,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ impl Command {
|
||||
chain: Arc<ChainSpec>,
|
||||
compression: Compression,
|
||||
inclusion_filter: InclusionFilter,
|
||||
phf: PerfectHashingFunction,
|
||||
phf: Option<PerfectHashingFunction>,
|
||||
) -> eyre::Result<()> {
|
||||
let factory = ProviderFactory::new(open_db_read_only(db_path, log_level)?, chain.clone());
|
||||
let provider = factory.provider()?;
|
||||
@@ -35,7 +35,7 @@ impl Command {
|
||||
let block_range =
|
||||
self.block_ranges(tip).first().expect("has been generated before").clone();
|
||||
|
||||
let filters = if self.with_filters {
|
||||
let filters = if let Some(phf) = self.with_filters.then_some(phf).flatten() {
|
||||
Filters::WithFilters(inclusion_filter, phf)
|
||||
} else {
|
||||
Filters::WithoutFilters
|
||||
|
||||
@@ -27,7 +27,7 @@ impl Command {
|
||||
chain: Arc<ChainSpec>,
|
||||
compression: Compression,
|
||||
inclusion_filter: InclusionFilter,
|
||||
phf: PerfectHashingFunction,
|
||||
phf: Option<PerfectHashingFunction>,
|
||||
) -> eyre::Result<()> {
|
||||
let factory = ProviderFactory::new(open_db_read_only(db_path, log_level)?, chain.clone());
|
||||
let provider = factory.provider()?;
|
||||
@@ -35,7 +35,7 @@ impl Command {
|
||||
let block_range =
|
||||
self.block_ranges(tip).first().expect("has been generated before").clone();
|
||||
|
||||
let filters = if self.with_filters {
|
||||
let filters = if let Some(phf) = self.with_filters.then_some(phf).flatten() {
|
||||
Filters::WithFilters(inclusion_filter, phf)
|
||||
} else {
|
||||
Filters::WithoutFilters
|
||||
|
||||
Reference in New Issue
Block a user