Have the scan flag blocks with change/branch/forwarded as notable

This commit is contained in:
Luke Parker 2024-08-24 17:30:02 -04:00
parent d5d1fc3eea
commit 945f31dfc7
3 changed files with 14 additions and 0 deletions

View file

@ -120,6 +120,7 @@ impl<S: ScannerFeed> ScannerDb<S> {
}
// TODO: This will be called from the Eventuality task yet this field is read by the scan task
// We need to write the argument for its safety
// TODO: retire_key needs to set the notable block
pub(crate) fn retire_key(txn: &mut impl DbTxn, key: KeyFor<S>) {
let mut keys: Vec<SeraiKeyDbEntry<BorshG<KeyFor<S>>>> =
ActiveKeys::get(txn).expect("retiring key yet no active keys");
@ -276,6 +277,10 @@ impl<S: ScannerFeed> ScannerDb<S> {
SerializedForwardedOutput::set(txn, id.as_ref(), &buf);
}
pub(crate) fn flag_notable(txn: &mut impl DbTxn, block_number: u64) {
NotableBlock::set(txn, block_number, &());
}
// TODO: Use a DbChannel here, and send the instructions to the report task and the outputs to
// the eventuality task? That way this cleans up after itself
pub(crate) fn set_in_instructions(

View file

@ -46,6 +46,7 @@ impl<D: Db, S: ScannerFeed> ContinuallyRan for ReportTask<D, S> {
for b in next_to_potentially_report ..= highest_reportable {
let mut txn = self.db.txn();
// If this block is notable, create the Batch(s) for it
if ScannerDb::<S>::is_block_notable(&txn, b) {
let in_instructions = ScannerDb::<S>::in_instructions(&txn, b)
.expect("reporting block which didn't set its InInstructions");

View file

@ -152,6 +152,14 @@ impl<D: Db, S: ScannerFeed> ContinuallyRan for ScanForOutputsTask<D, S> {
to do so at a higher level.
*/
if output.kind() != OutputType::External {
// While we don't report these outputs, we still need consensus on this block and
// accordingly still need to set it as notable
let balance = outputs.balance();
// We ensure it's over the dust limit to prevent people sending 1 satoshi from causing
// an invocation of a consensus/signing protocol
if balance.amount.0 >= self.feed.dust(balance.coin).0 {
ScannerDb::<S>::flag_notable(&mut txn, b);
}
continue;
}