mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 20:17:57 +00:00
check for lost race before warning (#2833)
This commit is contained in:
committed by
GitHub
parent
1e4517800b
commit
8eae0fa443
@@ -636,13 +636,26 @@ pub(crate) async fn handle_new_head(
|
||||
match imported_block_info(ctx, env, block_hash, &block_header).await? {
|
||||
Some(i) => imported_blocks_and_info.push((block_hash, block_header, i)),
|
||||
None => {
|
||||
// Such errors are likely spurious, but this prevents us from getting gaps
|
||||
// in the approval-db.
|
||||
tracing::warn!(
|
||||
target: LOG_TARGET,
|
||||
"Unable to gather info about imported block {:?}. Skipping chain.",
|
||||
(block_hash, block_header.number),
|
||||
);
|
||||
// It's possible that we've lost a race with finality.
|
||||
let (tx, rx) = oneshot::channel();
|
||||
ctx.send_message(
|
||||
ChainApiMessage::FinalizedBlockHash(block_header.number.clone(), tx).into()
|
||||
).await;
|
||||
|
||||
let lost_to_finality = match rx.await {
|
||||
Ok(Ok(Some(h))) if h != block_hash => true,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
if !lost_to_finality {
|
||||
// Such errors are likely spurious, but this prevents us from getting gaps
|
||||
// in the approval-db.
|
||||
tracing::warn!(
|
||||
target: LOG_TARGET,
|
||||
"Unable to gather info about imported block {:?}. Skipping chain.",
|
||||
(block_hash, block_header.number),
|
||||
);
|
||||
}
|
||||
|
||||
return Ok(Vec::new());
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user