Cesar Rodas před 1 rokem
rodič
revize
a76ecc677e
3 změnil soubory, kde provedl 20 přidání a 6 odebrání
  1. 9 0
      Cargo.lock
  2. 1 0
      Cargo.toml
  3. 10 6
      src/bin/dump.rs

+ 9 - 0
Cargo.lock

@@ -830,6 +830,15 @@ dependencies = [
 ]
 
 [[package]]
+name = "nostr-rs-relayer"
+version = "0.1.0"
+dependencies = [
+ "nostr-rs-storage",
+ "nostr-rs-types",
+ "thiserror",
+]
+
+[[package]]
 name = "nostr-rs-storage"
 version = "0.1.0"
 dependencies = [

+ 1 - 0
Cargo.toml

@@ -7,6 +7,7 @@ edition = "2021"
 members = [
     "crates/types",
     "crates/client",
+    "crates/relayer",
     "crates/storage"
 ]
 

+ 10 - 6
src/bin/dump.rs

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