wait for chain_tip_update before cancelling download in mempool_cancel_mined (#5322)

This commit is contained in:
Arya 2022-10-03 22:52:03 -04:00 committed by GitHub
parent cea622307a
commit 59d647cfa1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 1 deletions

View File

@ -394,7 +394,7 @@ async fn mempool_cancel_mined() -> Result<(), Report> {
mut mempool,
_peer_set,
mut state_service,
_chain_tip_change,
mut chain_tip_change,
_tx_verifier,
mut recent_syncs,
) = setup(network, u64::MAX).await;
@ -461,6 +461,21 @@ async fn mempool_cancel_mined() -> Result<(), Report> {
.await
.unwrap();
// Wait for the chain tip update
if let Err(timeout_error) = timeout(
CHAIN_TIP_UPDATE_WAIT_LIMIT,
chain_tip_change.wait_for_tip_change(),
)
.await
.map(|change_result| change_result.expect("unexpected chain tip update failure"))
{
info!(
timeout = ?humantime_seconds(CHAIN_TIP_UPDATE_WAIT_LIMIT),
?timeout_error,
"timeout waiting for chain tip change after committing block"
);
}
// This is done twice because after the first query the cancellation
// is picked up by select!, and after the second the mempool gets the
// result and the download future is removed.