mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 02:49:55 +00:00
feat: Add cli aliases for nanoreth compatibility, add --local
This commit is contained in:
@ -9,15 +9,19 @@ pub struct BlockSourceArgs {
|
||||
/// Example: /home/user/personal/evm-blocks
|
||||
///
|
||||
/// For S3, you can use environment variables like AWS_PROFILE, etc.
|
||||
#[arg(long)]
|
||||
#[arg(long, alias = "ingest-dir")]
|
||||
block_source: Option<String>,
|
||||
|
||||
#[arg(long)]
|
||||
#[arg(long, alias = "local-ingest-dir")]
|
||||
block_source_from_node: Option<String>,
|
||||
|
||||
/// Shorthand of --block-source=s3://hl-mainnet-evm-blocks
|
||||
#[arg(long = "s3", default_value_t = false)]
|
||||
#[arg(long, default_value_t = false)]
|
||||
s3: bool,
|
||||
|
||||
/// Shorthand of --block-source-from-node=~/hl/data/evm_blocks_and_receipts
|
||||
#[arg(long)]
|
||||
local: bool,
|
||||
}
|
||||
|
||||
impl BlockSourceArgs {
|
||||
@ -32,6 +36,10 @@ impl BlockSourceArgs {
|
||||
return Ok(BlockSourceConfig::s3_default().await);
|
||||
}
|
||||
|
||||
if self.local {
|
||||
return Ok(BlockSourceConfig::local_default());
|
||||
}
|
||||
|
||||
let Some(value) = self.block_source.as_ref() else {
|
||||
return Err(eyre::eyre!(
|
||||
"You need to specify a block source e.g., --s3 or --block-source=/path/to/blocks"
|
||||
|
||||
@ -35,6 +35,19 @@ impl BlockSourceConfig {
|
||||
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 {
|
||||
self.block_source_from_node = Some(block_source_from_node);
|
||||
self
|
||||
|
||||
Reference in New Issue
Block a user