Skip to content

Commit

Permalink
Warn when parsing packet cell fails
Browse files Browse the repository at this point in the history
  • Loading branch information
blckngm committed Aug 28, 2023
1 parent 8dd0d5b commit 848f74f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ serde = { version = "1.0.183", features = ["derive"] }
serde_with = "3.2.0"
tiny-keccak = { version = "2.0.2", features = ["keccak"] }
tokio = { version = "1.31.0", features = ["time"] }
tracing = "0.1.37"

[dev-dependencies]
axon-types = { git = "https://github.com/axonweb3/axon-contract", rev = "8c2338a" }
Expand Down
23 changes: 8 additions & 15 deletions src/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,6 @@ impl PacketCell {
}
}

macro_rules! or_continue {
($e:expr) => {
match $e {
Ok(a) => a,
Err(_) => continue,
}
};
}

async fn search_packet_cells(
client: &CkbRpcClient,
config: &Config,
Expand Down Expand Up @@ -130,15 +121,17 @@ async fn search_packet_cells(
let mut result = Vec::new();
for c in cells.objects {
let tx = client
.get_transaction(c.out_point.tx_hash)
.get_transaction(c.out_point.tx_hash.clone())
.await?
.transaction
.context("get transaction")?;
let p = or_continue!(parse_packet_tx(
tx,
c.out_point.index.value() as usize,
config
));
let p = match parse_packet_tx(tx, c.out_point.index.value() as usize, config) {
Ok(p) => p,
Err(e) => {
tracing::warn!("failed to parse packet tx {}: {e:#}", c.out_point.tx_hash);
continue;
}
};
result.push(p);
}
*cursor = Some(cells.last_cursor);
Expand Down

0 comments on commit 848f74f

Please sign in to comment.