Skip to content

Commit

Permalink
Improvements in blockchain scan
Browse files Browse the repository at this point in the history
  • Loading branch information
scx1332 committed Feb 27, 2024
1 parent 08ecd08 commit 19bc0cf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
12 changes: 9 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,12 +707,16 @@ async fn main_internal() -> Result<(), PaymentError> {
))?;
let web3 = payment_setup.get_provider(chain_cfg.chain_id)?;

let sender = Address::from_str(&scan_blockchain_options.sender).unwrap();
let sender = scan_blockchain_options
.sender
.map(|s| Address::from_str(&s).unwrap());

let scan_info = ScanDaoDbObj {
id: 0,
chain_id: chain_cfg.chain_id,
filter: format!("{sender:#x}"),
filter: sender
.map(|f| format!("{f:#x}"))
.unwrap_or("all".to_string()),
start_block: -1,
last_block: -1,
};
Expand Down Expand Up @@ -741,6 +745,8 @@ async fn main_internal() -> Result<(), PaymentError> {
scan_info
};

println!("scan_info: {:?}", scan_info);

let current_block = web3
.clone()
.eth_block_number()
Expand Down Expand Up @@ -808,7 +814,7 @@ async fn main_internal() -> Result<(), PaymentError> {
web3: web3.clone(),
erc20_address: chain_cfg.token.address,
chain_id: chain_cfg.chain_id,
filter_by_senders: Some([sender].to_vec()),
filter_by_senders: sender.map(|sender| [sender].to_vec()),
filter_by_receivers: None,
start_block,
scan_end_block: end_block,
Expand Down
15 changes: 7 additions & 8 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ pub struct ImportOptions {
#[derive(Debug, StructOpt)]
#[structopt(about = "Scan blockchain options")]
pub struct ScanBlockchainOptions {
#[structopt(short = "c", long = "chain-name", default_value = "polygon")]
#[structopt(short = "c", long = "chain-name", default_value = "holesky")]
pub chain_name: String,

#[structopt(short = "b", long = "from-block")]
Expand Down Expand Up @@ -255,12 +255,11 @@ pub struct ScanBlockchainOptions {
)]
pub blocks_at_once: u64,

#[structopt(
short = "a",
long = "address",
default_value = "0x09e4F0aE44D5E60D44A8928Af7531e6A862290bC"
)]
pub sender: String,
#[structopt(long = "import-balances")]
pub import_balances: bool,

#[structopt(short = "a", long = "address")]
pub sender: Option<String>,
}

#[derive(StructOpt)]
Expand All @@ -273,7 +272,7 @@ pub struct CheckWeb3RpcOptions {
#[derive(StructOpt)]
#[structopt(about = "Export history stats")]
pub struct ExportHistoryStatsOptions {
#[structopt(short = "c", long = "chain-name", default_value = "polygon")]
#[structopt(short = "c", long = "chain-name", default_value = "holesky")]
pub chain_name: String,

#[structopt(
Expand Down

0 comments on commit 19bc0cf

Please sign in to comment.