mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-11 21:49:26 +00:00
SlashReport signing and signature publication
This commit is contained in:
@@ -1,14 +1,9 @@
|
||||
use scale::Decode;
|
||||
use serai_db::{DbTxn, Db};
|
||||
|
||||
use primitives::task::ContinuallyRan;
|
||||
|
||||
use crate::{
|
||||
db::{
|
||||
RegisteredKeys, CosignerToCoordinatorMessages, BatchSignerToCoordinatorMessages,
|
||||
SlashReportSignerToCoordinatorMessages, TransactionSignerToCoordinatorMessages,
|
||||
},
|
||||
Coordinator,
|
||||
};
|
||||
use crate::{db::*, Coordinator};
|
||||
|
||||
mod db;
|
||||
|
||||
@@ -30,6 +25,7 @@ impl<D: Db, C: Coordinator> ContinuallyRan for CoordinatorTask<D, C> {
|
||||
let mut iterated = false;
|
||||
|
||||
for session in RegisteredKeys::get(&self.db).unwrap_or(vec![]) {
|
||||
// Publish the messages generated by this key's signers
|
||||
loop {
|
||||
let mut txn = self.db.txn();
|
||||
let Some(msg) = CosignerToCoordinatorMessages::try_recv(&mut txn, session) else {
|
||||
@@ -93,6 +89,26 @@ impl<D: Db, C: Coordinator> ContinuallyRan for CoordinatorTask<D, C> {
|
||||
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
// If this session signed its slash report, publish its signature
|
||||
{
|
||||
let mut txn = self.db.txn();
|
||||
if let Some(slash_report_signature) = SlashReportSignature::try_recv(&mut txn, session) {
|
||||
iterated = true;
|
||||
|
||||
self
|
||||
.coordinator
|
||||
.publish_slash_report_signature(
|
||||
<_>::decode(&mut slash_report_signature.as_slice()).unwrap(),
|
||||
)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
format!("couldn't send slash report signature to the coordinator: {e:?}")
|
||||
})?;
|
||||
|
||||
txn.commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Publish the Batches
|
||||
|
||||
Reference in New Issue
Block a user