|
@@ -1,6 +1,6 @@
|
|
use futures::Future;
|
|
use futures::Future;
|
|
-use nostr_rs_client::{Clients, Error as ClientError};
|
|
|
|
-use nostr_rs_storage::Db;
|
|
|
|
|
|
+use nostr_rs_client::{Error as ClientError, Relayers};
|
|
|
|
+use nostr_rs_storage::RocksDb;
|
|
use nostr_rs_types::{client::Subscribe, Request, Response};
|
|
use nostr_rs_types::{client::Subscribe, Request, Response};
|
|
use std::pin::Pin;
|
|
use std::pin::Pin;
|
|
use tokio::sync::mpsc;
|
|
use tokio::sync::mpsc;
|
|
@@ -29,13 +29,13 @@ fn on_connection(
|
|
#[tokio::main]
|
|
#[tokio::main]
|
|
async fn main() {
|
|
async fn main() {
|
|
env_logger::init();
|
|
env_logger::init();
|
|
- let clients = Clients::default();
|
|
|
|
|
|
+ let clients = Relayers::default();
|
|
clients.send(Subscribe::default().into()).await;
|
|
clients.send(Subscribe::default().into()).await;
|
|
|
|
|
|
let _ = clients
|
|
let _ = clients
|
|
- .connect_to("wss://relay.damus.io/", Some(on_connection))
|
|
|
|
|
|
+ .connect_to("wss://relay.damus.io/", 30, Some(on_connection))
|
|
.await;
|
|
.await;
|
|
- let db = Db::new("./db").expect("db");
|
|
|
|
|
|
+ let db = RocksDb::new("./db").expect("db");
|
|
|
|
|
|
loop {
|
|
loop {
|
|
println!("going into loop");
|
|
println!("going into loop");
|
|
@@ -44,7 +44,11 @@ async fn main() {
|
|
Response::Event(x) => {
|
|
Response::Event(x) => {
|
|
let event = x.event;
|
|
let event = x.event;
|
|
|
|
|
|
- let _ = db.store(&event);
|
|
|
|
|
|
+ if db.store(&event).expect("valid") {
|
|
|
|
+ panic!("\tStored");
|
|
|
|
+ } else {
|
|
|
|
+ println!("\tSkip");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
_ => {}
|
|
_ => {}
|
|
}
|
|
}
|