Skip to content

Commit

Permalink
chore: optimize log print format
Browse files Browse the repository at this point in the history
  • Loading branch information
liyukun committed Nov 7, 2023
1 parent 8aab161 commit b1d3657
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crates/relayer/src/chain/axon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,7 @@ impl AxonChain {
let mut ibc_cache = self.ibc_cache.write().unwrap();
cache_ics_tx_hash_with_event(&mut ibc_cache, event.clone(), tx_hash);
tracing::info!(
"{} transaciton {} committed to {}",
"🎉 {} transaciton {} committed to {}",
event.event_type().as_str(),
hex::encode(tx_hash),
self.id()
Expand Down
42 changes: 36 additions & 6 deletions crates/relayer/src/chain/axon/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,31 @@ impl CkbSubmitProcess {
let tx = Legacy(transaction_request);
let signature = self.contract.sign_transaction(&tx, from).await?;

self.contract
let result = self
.contract
.send_raw_transaction(tx.rlp_signed(&signature))
.await?
.await?
.expect("failed to send to image_cell_contract");
.await?;

if let Some(receipt) = result {
let tx_hash = hex::encode(receipt.transaction_hash);
tracing::info!(
"📖 cells upload transaction {tx_hash} has sent to Axon({})",
self.chain_id
);
}

Ok(())
}

async fn upload_headers(&self, headers: Vec<HeaderView>) -> eyre::Result<()> {
if headers.is_empty() {
return Ok(());
}
let (from_number, to_number) = (
headers.first().unwrap().inner.number,
headers.last().unwrap().inner.number,
);
let data = ckb_light_client::UpdateCall {
headers: headers.into_iter().map(Into::into).collect(),
}
Expand All @@ -151,11 +166,21 @@ impl CkbSubmitProcess {
let tx = Legacy(transaction_request);
let signature = self.contract.sign_transaction(&tx, from).await?;

self.contract
let result = self
.contract
.send_raw_transaction(tx.rlp_signed(&signature))
.await?
.await?
.expect("failed to send to light_client_contract");
.await?;

if let Some(receipt) = result {
let tx_hash = hex::encode(receipt.transaction_hash);
tracing::info!(
"📖 headers({} - {}) upload transaction {tx_hash} has sent to Axon({})",
u64::from(from_number),
u64::from(to_number),
self.chain_id
);
}

Ok(())
}
Expand Down Expand Up @@ -240,6 +265,10 @@ impl CkbSyncManager {
cell_processor.run().await;
});
self.cell_processors.insert(search_key, handle);
tracing::info!(
"new cell filter registered to sync from block {}",
self.start_tip_number
);
Ok(true)
}

Expand Down Expand Up @@ -269,6 +298,7 @@ impl CkbSyncManager {
header_processor.run().await;
});
self.header_processor = Some(handle);
tracing::info!("start to sync CKB headers from block {start_block_number}");
Ok(true)
}

Expand Down
2 changes: 1 addition & 1 deletion crates/relayer/src/chain/ckb4ibc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ impl ChainEndpoint for Ckb4IbcChain {
.and_then(|tx_hash| {
let confirms = 3;
info!(
"{:?} transaction {} committed to {}, wait {confirms} blocks confirmation",
"🎉 {:?} transaction {} committed to {}, wait {confirms} blocks confirmation",
*msg_type,
hex::encode(&tx_hash),
self.id()
Expand Down

0 comments on commit b1d3657

Please sign in to comment.