|
@@ -1,5 +1,4 @@
|
|
use futures::Future;
|
|
use futures::Future;
|
|
-use nostr_rs_client::Event;
|
|
|
|
use nostr_rs_rocksdb::RocksDb;
|
|
use nostr_rs_rocksdb::RocksDb;
|
|
use nostr_rs_types::{types::Filter, Request, Response};
|
|
use nostr_rs_types::{types::Filter, Request, Response};
|
|
use std::{collections::HashMap, env, fs, pin::Pin, sync::Arc};
|
|
use std::{collections::HashMap, env, fs, pin::Pin, sync::Arc};
|
|
@@ -15,7 +14,7 @@ mod config;
|
|
use config::Config;
|
|
use config::Config;
|
|
|
|
|
|
fn on_connection(
|
|
fn on_connection(
|
|
- host: &Url,
|
|
|
|
|
|
+ host: Url,
|
|
_socket: mpsc::Sender<Request>,
|
|
_socket: mpsc::Sender<Request>,
|
|
) -> Pin<Box<dyn Future<Output = ()> + Send>> {
|
|
) -> Pin<Box<dyn Future<Output = ()> + Send>> {
|
|
Box::pin(async move {})
|
|
Box::pin(async move {})
|
|
@@ -64,11 +63,11 @@ async fn main() {
|
|
println!("{:#?}", config);
|
|
println!("{:#?}", config);
|
|
|
|
|
|
let db = RocksDb::new(&config.db_path).expect("db");
|
|
let db = RocksDb::new(&config.db_path).expect("db");
|
|
- let client_pool = config
|
|
|
|
|
|
+ let mut client_pool = config
|
|
.relayers
|
|
.relayers
|
|
.iter()
|
|
.iter()
|
|
.fold(nostr_rs_client::Pool::new(), |clients, relayer_url| {
|
|
.fold(nostr_rs_client::Pool::new(), |clients, relayer_url| {
|
|
- clients.connect_to(relayer_url.clone(), Some(on_connection))
|
|
|
|
|
|
+ clients.connect_to(relayer_url.clone())
|
|
});
|
|
});
|
|
|
|
|
|
let initial_subscription = Filter {
|
|
let initial_subscription = Filter {
|
|
@@ -80,7 +79,14 @@ async fn main() {
|
|
..Default::default()
|
|
..Default::default()
|
|
};
|
|
};
|
|
|
|
|
|
- println!("Initial subscription: {:?}", initial_subscription);
|
|
|
|
|
|
+ let _ = client_pool.subscribe(initial_subscription.into()).await;
|
|
|
|
+ loop {
|
|
|
|
+ tokio::select! {
|
|
|
|
+ Some((event, url)) = client_pool.recv() => {
|
|
|
|
+ println!("Recv: {} from {}", serde_json::to_string(&event).expect("valid json"), url);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
/*
|
|
/*
|
|
let db = RocksDb::new("./relayer-db").expect("db");
|
|
let db = RocksDb::new("./relayer-db").expect("db");
|