mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 20:29:23 +00:00
Make progres on handling NewSet events
Further bones out the coordinator.
This commit is contained in:
@@ -1,22 +1,30 @@
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_variables)]
|
||||
#![allow(unused_mut)]
|
||||
|
||||
use serai_db::Db;
|
||||
use serai_db::{Db, MemDb};
|
||||
|
||||
use serai_client::Serai;
|
||||
|
||||
mod db;
|
||||
pub use db::*;
|
||||
|
||||
mod transaction;
|
||||
pub use transaction::Transaction as TributaryTransaction;
|
||||
|
||||
mod p2p;
|
||||
pub use p2p::*;
|
||||
|
||||
mod substrate;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
async fn run<D: Db>(db: D, serai: Serai) {
|
||||
async fn run<D: Db, P: P2p>(db: D, p2p: P, serai: Serai) {
|
||||
let mut db = MainDb::new(db);
|
||||
|
||||
let mut last_substrate_block = 0; // TODO: Load from DB
|
||||
|
||||
loop {
|
||||
match substrate::handle_new_blocks(&serai, &mut last_substrate_block).await {
|
||||
match substrate::handle_new_blocks(&mut db, &p2p, &serai, &mut last_substrate_block).await {
|
||||
Ok(()) => {}
|
||||
Err(e) => log::error!("couldn't communicate with serai node: {e}"),
|
||||
}
|
||||
@@ -29,5 +37,16 @@ async fn run<D: Db>(db: D, serai: Serai) {
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
// Open the database
|
||||
let db = MemDb::new(); // TODO
|
||||
let p2p = LocalP2p {}; // TODO
|
||||
let serai = || async {
|
||||
loop {
|
||||
let Ok(serai) = Serai::new("ws://127.0.0.1:9944").await else {
|
||||
log::error!("couldn't connect to the Serai node");
|
||||
continue
|
||||
};
|
||||
return serai;
|
||||
}
|
||||
};
|
||||
run(db, p2p, serai().await).await
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user