mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-09 04:39:24 +00:00
Integrate coordinator with MessageQueue and RocksDB
Also resolves a couple TODOs.
This commit is contained in:
@@ -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!()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user