Split reporting Batches to the signer from the Batch test

This commit is contained in:
Luke Parker
2024-12-30 11:03:52 -05:00
parent f0094b3c7c
commit 26ccff25a1
5 changed files with 142 additions and 95 deletions

View File

@@ -30,6 +30,8 @@ mod index;
mod scan;
/// Task which creates Batches for Substrate.
mod batch;
/// Task which reports Batches for signing.
mod report;
/// Task which handles events from Substrate once we can.
mod substrate;
/// Check blocks for transactions expected to eventually occur.
@@ -380,6 +382,7 @@ impl<S: ScannerFeed> Scanner<S> {
let index_task = index::IndexTask::new(db.clone(), feed.clone(), start_block).await;
let scan_task = scan::ScanTask::new(db.clone(), feed.clone(), start_block);
let batch_task = batch::BatchTask::<_, S>::new(db.clone(), start_block);
let report_task = report::ReportTask::<_, S>::new(db.clone());
let substrate_task = substrate::SubstrateTask::<_, S>::new(db.clone());
let eventuality_task =
eventuality::EventualityTask::<_, _, _>::new(db, feed, scheduler, start_block);
@@ -387,6 +390,7 @@ impl<S: ScannerFeed> Scanner<S> {
let (index_task_def, _index_handle) = Task::new();
let (scan_task_def, scan_handle) = Task::new();
let (batch_task_def, batch_handle) = Task::new();
let (report_task_def, report_handle) = Task::new();
let (substrate_task_def, substrate_handle) = Task::new();
let (eventuality_task_def, eventuality_handle) = Task::new();
@@ -394,9 +398,11 @@ impl<S: ScannerFeed> Scanner<S> {
tokio::spawn(index_task.continually_run(index_task_def, vec![scan_handle.clone()]));
// Upon scanning a block, creates the batches for it
tokio::spawn(scan_task.continually_run(scan_task_def, vec![batch_handle]));
// Upon creating batches for a block, we do nothing (as the burden is on Substrate which won't
// be immediately ready)
tokio::spawn(batch_task.continually_run(batch_task_def, vec![]));
// Upon creating batches for a block, we run the report task
tokio::spawn(batch_task.continually_run(batch_task_def, vec![report_handle]));
// Upon reporting the batches for signing, we do nothing (as the burden is on a tributary which
// won't immediately yield a result)
tokio::spawn(report_task.continually_run(report_task_def, vec![]));
// Upon handling an event from Substrate, we run the Eventuality task (as it's what's affected)
tokio::spawn(substrate_task.continually_run(substrate_task_def, vec![eventuality_handle]));
// Upon handling the Eventualities in a block, we run the scan task as we've advanced the