mirror of
https://github.com/serai-dex/serai.git
synced 2024-12-25 13:09:30 +00:00
Read NetworkId from ScannerFeed trait, not env
This commit is contained in:
parent
1a08d50e16
commit
53567e91c8
2 changed files with 7 additions and 12 deletions
|
@ -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<S: ScannerFeed>(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
|
||||
|
|
|
@ -182,7 +182,7 @@ pub async fn main_loop<
|
|||
scheduler: Sch,
|
||||
publisher: impl TransactionPublisher<TransactionFor<Sch::SignableTransaction>>,
|
||||
) {
|
||||
let mut coordinator = Coordinator::new(db.clone());
|
||||
let mut coordinator = Coordinator::new::<S>(db.clone());
|
||||
|
||||
let mut key_gen = key_gen::<K>();
|
||||
let mut scanner = Scanner::new(db.clone(), feed.clone(), scheduler.clone()).await;
|
||||
|
|
Loading…
Reference in a new issue