Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: try resend tx to axon #12

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 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 emitter-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ reqwest = { version = "0.11", features = ["json"], optional = true }
jsonrpc-core = "18.0"
async-trait = "0.1"
tokio = { version = "1", features = ["time"] }
log = "0.4"

[features]
default = ["client"]
Expand Down
4 changes: 2 additions & 2 deletions emitter-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ macro_rules! rpc_get {
Ok(r) => break r,
Err(e) => match e.kind() {
ConnectionRefused | ConnectionReset | ConnectionAborted | BrokenPipe => {
panic!("{e}")
log::error!("rpc get with serious error: {e}")
}
_ => (),
_ => log::warn!("rpc get with error: {e}"),
},
}
}
Expand Down
9 changes: 4 additions & 5 deletions emitter/src/emit_data/eth_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ pub async fn send_eth_tx(axon_url: &str, data: Vec<u8>, to: Address) -> Result<(
let tx = Legacy(transaction_request);
let signature: Signature = wallet.sign_transaction(&tx).await?;

provider
.send_raw_transaction(tx.rlp_signed(&signature))
.await?
.await?
.expect("failed to send eth tx");
let tx_raw = tx.rlp_signed(&signature);
while let None = provider.send_raw_transaction(tx_raw.clone()).await?.await? {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the retry frequency be too high?

log::warn!("can't get axon tx receipt, send tx fails, retry...")
}

Ok(())
}
Expand Down
17 changes: 10 additions & 7 deletions emitter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,19 @@ async fn main() {
}

async fn submit_cells(axon_url: &str, submits: Vec<Submit>) {
if let Err(e) = send_eth_tx(axon_url, convert_blocks(submits), IMAGE_CELL_ADDRESS).await {
println!("emitter submit cells tx error: {e}")
};
let data = convert_blocks(submits);

while let Err(e) = send_eth_tx(axon_url, data.clone(), IMAGE_CELL_ADDRESS).await {
log::warn!("emitter submit cells tx error: {e}")
}
}

async fn submit_headers(axon_url: &str, headers: Vec<HeaderViewWithExtension>) {
if let Err(e) = send_eth_tx(axon_url, convert_headers(headers), CKB_LIGHT_CLIENT_ADDRESS).await
{
println!("emitter submit headers tx error: {e}")
};
let data = convert_headers(headers);

while let Err(e) = send_eth_tx(axon_url, data.clone(), CKB_LIGHT_CLIENT_ADDRESS).await {
log::warn!("emitter submit headers tx error: {e}")
}
}

struct ScanTipInner(AtomicPtr<IndexerTip>);
Expand Down