Pārlūkot izejas kodu

Added dump crate

Cesar Rodas 3 mēneši atpakaļ
vecāks
revīzija
4caca04477
4 mainītis faili ar 37 papildinājumiem un 6 dzēšanām
  1. 18 0
      Cargo.lock
  2. 1 1
      Cargo.toml
  3. 18 0
      crates/dump/Cargo.toml
  4. 0 5
      crates/dump/src/main.rs

+ 18 - 0
Cargo.lock

@@ -907,6 +907,24 @@ dependencies = [
 ]
 
 [[package]]
+name = "nostr-rs-dump"
+version = "0.1.0"
+dependencies = [
+ "env_logger",
+ "futures",
+ "futures-util",
+ "instant-acme",
+ "log",
+ "nostr-rs-client",
+ "nostr-rs-types",
+ "serde",
+ "serde_json",
+ "thiserror",
+ "tokio",
+ "toml",
+]
+
+[[package]]
 name = "nostr-rs-relayer"
 version = "0.1.0"
 dependencies = [

+ 1 - 1
Cargo.toml

@@ -9,7 +9,7 @@ members = [
     "crates/client",
     "crates/relayer",
     "crates/storage/base",
-    "crates/storage/rocksdb",
+    "crates/storage/rocksdb", "crates/dump",
 ]
 
 [dependencies]

+ 18 - 0
crates/dump/Cargo.toml

@@ -0,0 +1,18 @@
+[package]
+name = "nostr-rs-dump"
+version = "0.1.0"
+edition = "2021"
+
+[dependencies]
+nostr-rs-types = { path = "../types" }
+nostr-rs-client = { path = "../client" }
+tokio = { version = "1.26.0", features = ["full"] }
+env_logger = "0.10.0"
+futures-util = "0.3.27"
+log = "0.4.17"
+thiserror = "1.0.40"
+futures = "0.3.28"
+instant-acme = "0.2.0"
+serde = "1.0.183"
+toml = "0.7.6"
+serde_json = "1.0.105"

+ 0 - 5
src/bin/dump.rs → crates/dump/src/main.rs

@@ -1,7 +1,5 @@
 use futures::Future;
 use nostr_rs_client::{Error as ClientError, Event, Pool};
-use nostr_rs_rocksdb::RocksDb;
-use nostr_rs_storage_base::Storage;
 use nostr_rs_types::{client::Subscribe, Request, Response};
 use std::pin::Pin;
 use tokio::sync::mpsc;
@@ -43,7 +41,6 @@ async fn main() {
         .expect("valid url");
 
     clients.send(Subscribe::default().into()).await;
-    let db = RocksDb::new("./db").expect("db");
 
     loop {
         if let Some((msg, relayed_by)) = clients.recv().await {
@@ -51,8 +48,6 @@ async fn main() {
                 Event::Response(r) => match *r {
                     Response::Event(x) => {
                         println!("{} => {:?}", relayed_by, x);
-                        let event = x.event;
-                        db.store(&event).expect("valid");
                     }
                     Response::EndOfStoredEvents(_) => {}
                     msg => {