feat: Add cli aliases for nanoreth compatibility, add --local

This commit is contained in:
sprites0
2025-07-04 18:24:27 +00:00
parent f6830a67cd
commit 5987f147f1
2 changed files with 24 additions and 3 deletions

View File

@ -9,15 +9,19 @@ pub struct BlockSourceArgs {
/// Example: /home/user/personal/evm-blocks /// Example: /home/user/personal/evm-blocks
/// ///
/// For S3, you can use environment variables like AWS_PROFILE, etc. /// For S3, you can use environment variables like AWS_PROFILE, etc.
#[arg(long)] #[arg(long, alias = "ingest-dir")]
block_source: Option<String>, block_source: Option<String>,
#[arg(long)] #[arg(long, alias = "local-ingest-dir")]
block_source_from_node: Option<String>, block_source_from_node: Option<String>,
/// Shorthand of --block-source=s3://hl-mainnet-evm-blocks /// Shorthand of --block-source=s3://hl-mainnet-evm-blocks
#[arg(long = "s3", default_value_t = false)] #[arg(long, default_value_t = false)]
s3: bool, s3: bool,
/// Shorthand of --block-source-from-node=~/hl/data/evm_blocks_and_receipts
#[arg(long)]
local: bool,
} }
impl BlockSourceArgs { impl BlockSourceArgs {
@ -32,6 +36,10 @@ impl BlockSourceArgs {
return Ok(BlockSourceConfig::s3_default().await); return Ok(BlockSourceConfig::s3_default().await);
} }
if self.local {
return Ok(BlockSourceConfig::local_default());
}
let Some(value) = self.block_source.as_ref() else { let Some(value) = self.block_source.as_ref() else {
return Err(eyre::eyre!( return Err(eyre::eyre!(
"You need to specify a block source e.g., --s3 or --block-source=/path/to/blocks" "You need to specify a block source e.g., --s3 or --block-source=/path/to/blocks"

View File

@ -35,6 +35,19 @@ impl BlockSourceConfig {
Self { source_type: BlockSourceType::Local { path }, block_source_from_node: None } Self { source_type: BlockSourceType::Local { path }, block_source_from_node: None }
} }
pub fn local_default() -> Self {
Self {
source_type: BlockSourceType::Local {
path: home_dir()
.expect("home dir not found")
.join("hl")
.join("data")
.join("evm_blocks_and_receipts"),
},
block_source_from_node: None,
}
}
pub fn with_block_source_from_node(mut self, block_source_from_node: String) -> Self { pub fn with_block_source_from_node(mut self, block_source_from_node: String) -> Self {
self.block_source_from_node = Some(block_source_from_node); self.block_source_from_node = Some(block_source_from_node);
self self