Integrate coordinator with MessageQueue and RocksDB

Also resolves a couple TODOs.
This commit is contained in:
Luke Parker
2023-07-18 01:53:51 -04:00
parent a05961974a
commit a7c9c1ef55
12 changed files with 309 additions and 237 deletions

View File

@@ -1 +1,38 @@
use std::{
sync::Arc,
collections::{VecDeque, HashMap},
};
use serai_client::primitives::NetworkId;
use processor_messages::CoordinatorMessage;
use tokio::sync::RwLock;
use crate::processors::{Message, Processors};
pub mod tributary;
#[derive(Clone)]
pub struct MemProcessors(pub Arc<RwLock<HashMap<NetworkId, VecDeque<CoordinatorMessage>>>>);
impl MemProcessors {
#[allow(clippy::new_without_default)]
pub fn new() -> MemProcessors {
MemProcessors(Arc::new(RwLock::new(HashMap::new())))
}
}
#[async_trait::async_trait]
impl Processors for MemProcessors {
async fn send(&self, network: NetworkId, msg: CoordinatorMessage) {
let mut processors = self.0.write().await;
let processor = processors.entry(network).or_insert_with(VecDeque::new);
processor.push_back(msg);
}
async fn recv(&mut self) -> Message {
todo!()
}
async fn ack(&mut self, _: Message) {
todo!()
}
}

View File

@@ -19,10 +19,12 @@ use processor_messages::{
use tributary::{Transaction as TransactionTrait, Tributary};
use crate::{
processors::MemProcessors,
LocalP2p,
tributary::{TributaryDb, Transaction, TributarySpec, scanner::handle_new_blocks},
tests::tributary::{new_keys, new_spec, new_tributaries, run_tributaries, wait_for_tx_inclusion},
tests::{
MemProcessors,
tributary::{new_keys, new_spec, new_tributaries, run_tributaries, wait_for_tx_inclusion},
},
};
#[tokio::test]