Set pending_sync when last-minute check fails in Esplora

This commit is contained in:
Elias Rohrer 2023-11-16 11:56:17 +01:00
parent 82f4c10e18
commit d2ecf0766c
No known key found for this signature in database
GPG key ID: 36153082BDF676FD

View file

@ -114,7 +114,8 @@ where
Ok(unconfirmed_txs) => { Ok(unconfirmed_txs) => {
// Double-check the tip hash. If it changed, a reorg happened since // Double-check the tip hash. If it changed, a reorg happened since
// we started syncing and we need to restart last-minute. // we started syncing and we need to restart last-minute.
let check_tip_hash = maybe_await!(self.client.get_tip_hash())?; match maybe_await!(self.client.get_tip_hash()) {
Ok(check_tip_hash) => {
if check_tip_hash != tip_hash { if check_tip_hash != tip_hash {
tip_hash = check_tip_hash; tip_hash = check_tip_hash;
@ -123,7 +124,22 @@ where
continue; continue;
} }
num_unconfirmed += unconfirmed_txs.len(); num_unconfirmed += unconfirmed_txs.len();
sync_state.sync_unconfirmed_transactions(&confirmables, unconfirmed_txs); sync_state.sync_unconfirmed_transactions(
&confirmables,
unconfirmed_txs
);
}
Err(err) => {
// (Semi-)permanent failure, retry later.
log_error!(self.logger,
"Failed during transaction sync, aborting. Synced so far: {} confirmed, {} unconfirmed.",
num_confirmed,
num_unconfirmed
);
sync_state.pending_sync = true;
return Err(TxSyncError::from(err));
}
}
}, },
Err(err) => { Err(err) => {
// (Semi-)permanent failure, retry later. // (Semi-)permanent failure, retry later.
@ -162,18 +178,34 @@ where
Ok(confirmed_txs) => { Ok(confirmed_txs) => {
// Double-check the tip hash. If it changed, a reorg happened since // Double-check the tip hash. If it changed, a reorg happened since
// we started syncing and we need to restart last-minute. // we started syncing and we need to restart last-minute.
let check_tip_hash = maybe_await!(self.client.get_tip_hash())?; match maybe_await!(self.client.get_tip_hash()) {
Ok(check_tip_hash) => {
if check_tip_hash != tip_hash { if check_tip_hash != tip_hash {
tip_hash = check_tip_hash; tip_hash = check_tip_hash;
log_debug!(self.logger,
"Encountered inconsistency during transaction sync, restarting.");
sync_state.pending_sync = true;
continue; continue;
} }
num_confirmed += confirmed_txs.len(); num_confirmed += confirmed_txs.len();
sync_state.sync_confirmed_transactions( sync_state.sync_confirmed_transactions(
&confirmables, &confirmables,
confirmed_txs, confirmed_txs
); );
} }
Err(err) => {
// (Semi-)permanent failure, retry later.
log_error!(self.logger,
"Failed during transaction sync, aborting. Synced so far: {} confirmed, {} unconfirmed.",
num_confirmed,
num_unconfirmed
);
sync_state.pending_sync = true;
return Err(TxSyncError::from(err));
}
}
}
Err(InternalError::Inconsistency) => { Err(InternalError::Inconsistency) => {
// Immediately restart syncing when we encounter any inconsistencies. // Immediately restart syncing when we encounter any inconsistencies.
log_debug!(self.logger, "Encountered inconsistency during transaction sync, restarting."); log_debug!(self.logger, "Encountered inconsistency during transaction sync, restarting.");