Tidy messages, publish all Batches to the coordinator

Prior, we published SignedBatches, yet Batches are necessary for auditing
purposes.
This commit is contained in:
Luke Parker
2024-09-09 03:06:37 -04:00
parent a3cb514400
commit 0078858c1c
6 changed files with 89 additions and 124 deletions

View File

@@ -95,6 +95,20 @@ impl<D: Db, C: Coordinator> ContinuallyRan for CoordinatorTask<D, C> {
}
}
// Publish the Batches
{
let mut txn = self.db.txn();
while let Some(batch) = scanner::Batches::try_recv(&mut txn) {
iterated = true;
self
.coordinator
.publish_batch(batch)
.await
.map_err(|e| format!("couldn't publish Batch: {e:?}"))?;
}
txn.commit();
}
// Publish the signed Batches
{
let mut txn = self.db.txn();
@@ -108,7 +122,7 @@ impl<D: Db, C: Coordinator> ContinuallyRan for CoordinatorTask<D, C> {
db::LastPublishedBatch::set(&mut txn, &batch.batch.id);
self
.coordinator
.publish_batch(batch)
.publish_signed_batch(batch)
.await
.map_err(|e| format!("couldn't publish Batch: {e:?}"))?;
next_batch += 1;

View File

@@ -46,8 +46,11 @@ pub trait Coordinator: 'static + Send + Sync {
/// Send a `messages::sign::ProcessorMessage`.
async fn send(&mut self, message: ProcessorMessage) -> Result<(), Self::EphemeralError>;
/// Publish a `Batch`.
async fn publish_batch(&mut self, batch: Batch) -> Result<(), Self::EphemeralError>;
/// Publish a `SignedBatch`.
async fn publish_batch(&mut self, batch: SignedBatch) -> Result<(), Self::EphemeralError>;
async fn publish_signed_batch(&mut self, batch: SignedBatch) -> Result<(), Self::EphemeralError>;
}
/// An object capable of publishing a transaction.