From 53567e91c8314fb62c7971c34236bdafeae1dee3 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Thu, 19 Sep 2024 02:58:02 -0400 Subject: [PATCH] Read NetworkId from ScannerFeed trait, not env --- processor/bin/src/coordinator.rs | 17 ++++++----------- processor/bin/src/lib.rs | 2 +- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/processor/bin/src/coordinator.rs b/processor/bin/src/coordinator.rs index 6fe5aea0..e05712cf 100644 --- a/processor/bin/src/coordinator.rs +++ b/processor/bin/src/coordinator.rs @@ -5,13 +5,15 @@ use tokio::sync::mpsc; use scale::Encode; use serai_client::{ - primitives::{NetworkId, Signature}, + primitives::Signature, validator_sets::primitives::Session, in_instructions::primitives::{Batch, SignedBatch}, }; use serai_db::{Get, DbTxn, Db, create_db, db_channel}; -use serai_env as env; + +use scanner::ScannerFeed; + use message_queue::{Service, Metadata, client::MessageQueue}; create_db! { @@ -60,18 +62,11 @@ pub(crate) struct Coordinator { } impl Coordinator { - pub(crate) fn new(db: crate::Db) -> Self { + pub(crate) fn new(db: crate::Db) -> Self { let (received_message_send, received_message_recv) = mpsc::unbounded_channel(); let (sent_message_send, mut sent_message_recv) = mpsc::unbounded_channel(); - let network_id = match env::var("NETWORK").expect("network wasn't specified").as_str() { - "bitcoin" => NetworkId::Bitcoin, - "ethereum" => NetworkId::Ethereum, - "monero" => NetworkId::Monero, - _ => panic!("unrecognized network"), - }; - // TODO: Read this from ScannerFeed - let service = Service::Processor(network_id); + let service = Service::Processor(S::NETWORK); let message_queue = Arc::new(MessageQueue::from_env(service)); // Spawn a task to move messages from the message-queue to our database so we can achieve diff --git a/processor/bin/src/lib.rs b/processor/bin/src/lib.rs index 651514ad..662eafb9 100644 --- a/processor/bin/src/lib.rs +++ b/processor/bin/src/lib.rs @@ -182,7 +182,7 @@ pub async fn main_loop< scheduler: Sch, publisher: impl TransactionPublisher>, ) { - let mut coordinator = Coordinator::new(db.clone()); + let mut coordinator = Coordinator::new::(db.clone()); let mut key_gen = key_gen::(); let mut scanner = Scanner::new(db.clone(), feed.clone(), scheduler.clone()).await;