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: do validation after adding utxos and txs #6114

Merged
merged 2 commits into from
Feb 1, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ where
Some(peer) => match self.attempt_sync(peer.clone()).await {
Ok((num_outputs_recovered, final_height, final_amount, elapsed)) => {
debug!(target: LOG_TARGET, "Scanned to height #{}", final_height);
self.finalize(num_outputs_recovered, final_height, final_amount, elapsed)?;
self.finalize(num_outputs_recovered, final_height, final_amount, elapsed)
.await?;
return Ok(());
},
Err(e) => {
Expand Down Expand Up @@ -146,13 +147,18 @@ where
}
}

fn finalize(
&self,
async fn finalize(
&mut self,
num_outputs_recovered: u64,
final_height: u64,
total_value: MicroMinotari,
elapsed: Duration,
) -> Result<(), UtxoScannerError> {
if num_outputs_recovered > 0 {
// this is a best effort, if this fails, its very likely that it's already busy with a validation.
let _result = self.resources.output_manager_service.validate_txos().await;
let _result = self.resources.transaction_service.validate_transactions().await;
}
self.publish_event(UtxoScannerEvent::Progress {
current_height: final_height,
tip_height: final_height,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ impl OutputManagerServiceMock {
e
});
},
OutputManagerRequest::ValidateUtxos => {},
_ => panic!("Output Manager Service Mock does not support this call"),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ impl TransactionServiceMock {
e
});
},
TransactionServiceRequest::ValidateTransactions => {},
_ => panic!("Transaction Service Mock does not support this call"),
}
}
Expand Down
Loading