From 85dafec2a9db888a985aaa568b983858454f650e Mon Sep 17 00:00:00 2001 From: Niko PLP Date: Sun, 19 May 2024 10:59:16 +0300 Subject: [PATCH] fix warnings --- README.md | 2 +- nextgraph/examples/in_memory.rs | 4 ++++ nextgraph/examples/persistent.rs | 4 ++++ nextgraph/src/lib.rs | 32 +++++++++++++++++++++++++ ng-broker/src/rocksdb_server_storage.rs | 2 +- ng-repo/src/branch.rs | 2 ++ ng-sdk-js/prepare-node.js | 2 +- ng-verifier/src/verifier.rs | 6 +++++ 8 files changed, 51 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cc37a03..9088d5a 100644 --- a/README.md +++ b/README.md @@ -183,7 +183,7 @@ For building the apps, see this [documentation](ng-app/README.md). #### OpenBSD On OpenBSD, a conflict between the installed LibreSSL library and the reqwest crate, needs a bit of attention. -Before compiling the daemon for OpenBSD, please comment out lines 38-39 of `ng-net/Cargo.toml`. This will be solved soon by using `resolver = "2"`. +Before compiling the daemon for OpenBSD, please comment out lines 41-42 of `ng-net/Cargo.toml`. This will be solved soon by using `resolver = "2"`. ``` #[target.'cfg(target_arch = "wasm32")'.dependencies] diff --git a/nextgraph/examples/in_memory.rs b/nextgraph/examples/in_memory.rs index 03d451c..558a668 100644 --- a/nextgraph/examples/in_memory.rs +++ b/nextgraph/examples/in_memory.rs @@ -159,6 +159,10 @@ async fn main() -> std::io::Result<()> { let error_reason = status[0].3.as_ref().unwrap(); assert!(error_reason == "NoiseHandshakeFailed" || error_reason == "ConnectionError"); + // then you can make some calls to the APP protocol + // with app_request or app_request_stream + // more to be detailed soon. + // Then we should disconnect user_disconnect(&user_id).await?; diff --git a/nextgraph/examples/persistent.rs b/nextgraph/examples/persistent.rs index 2c3af54..1ff38cf 100644 --- a/nextgraph/examples/persistent.rs +++ b/nextgraph/examples/persistent.rs @@ -142,6 +142,10 @@ async fn main() -> std::io::Result<()> { let error_reason = status[0].3.as_ref().unwrap(); assert!(error_reason == "NoiseHandshakeFailed" || error_reason == "ConnectionError"); + // then you can make some calls to the APP protocol + // with app_request or app_request_stream + // more to be detailed soon. + // Then we should disconnect user_disconnect(&user_id).await?; diff --git a/nextgraph/src/lib.rs b/nextgraph/src/lib.rs index bdf844b..9dbf3a0 100644 --- a/nextgraph/src/lib.rs +++ b/nextgraph/src/lib.rs @@ -41,6 +41,38 @@ //! // initialize the local_broker with in-memory config. //! // all sessions will be lost when the program exits //! init_local_broker(Box::new(|| LocalBrokerConfig::InMemory)).await; +//! +//! // see https://git.nextgraph.org/NextGraph/nextgraph-rs/src/branch/master/nextgraph/examples/in_memory.md +//! // for a full example of what the Rust API gives you +//! +//! Ok(()) +//! } +//! ``` +//! +//! ## Persistent +//! +//! With this config, the encrypted wallet, session information, outbox, and all user data will be saved locally, with encryption at rest. +//! +//! ``` +//! use nextgraph::local_broker::{init_local_broker, LocalBrokerConfig}; +//! +//! #[async_std::main] +//! async fn main() -> std::io::Result<()> { +//! // initialize the local_broker with in-memory config. +//! // all sessions will be lost when the program exits +//! let mut current_path = current_dir()?; +//! current_path.push(".ng"); +//! current_path.push("example"); +//! create_dir_all(current_path.clone())?; +//! +//! // initialize the local_broker with config to save to disk in a folder called `.ng/example` in the current directory +//! init_local_broker(Box::new(move || { +//! LocalBrokerConfig::BasePath(current_path.clone()) +//! })).await; +//! +//! // see https://git.nextgraph.org/NextGraph/nextgraph-rs/src/branch/master/nextgraph/examples/persistent.md +//! // for a full example of what the Rust API gives you +//! //! Ok(()) //! } //! ``` diff --git a/ng-broker/src/rocksdb_server_storage.rs b/ng-broker/src/rocksdb_server_storage.rs index 685104f..290f8f5 100644 --- a/ng-broker/src/rocksdb_server_storage.rs +++ b/ng-broker/src/rocksdb_server_storage.rs @@ -169,7 +169,7 @@ impl RocksDbServerStorage { pub(crate) fn next_seq_for_peer(&self, peer: &PeerId, seq: u64) -> Result<(), ServerError> { // for now we don't use the hashmap. // TODO: let's see if the lock is even needed - let _ = self.peers_last_seq.lock(); + let _peers_last_seq = self.peers_last_seq.lock(); let mut filename = self.peers_last_seq_path.clone(); filename.push(format!("{}", peer)); diff --git a/ng-repo/src/branch.rs b/ng-repo/src/branch.rs index 0f4bf3e..cd9f1bc 100644 --- a/ng-repo/src/branch.rs +++ b/ng-repo/src/branch.rs @@ -48,12 +48,14 @@ impl BranchV0 { } } +#[allow(dead_code)] #[derive(Debug)] pub struct DagNode { pub future: HashSet, pub past: HashSet, } +#[allow(dead_code)] struct Dag<'a>(&'a HashMap); impl fmt::Display for DagNode { diff --git a/ng-sdk-js/prepare-node.js b/ng-sdk-js/prepare-node.js index 531b867..17b8927 100644 --- a/ng-sdk-js/prepare-node.js +++ b/ng-sdk-js/prepare-node.js @@ -6,7 +6,7 @@ const PATH_README = './pkg-node/README.md'; const pkg_json = fs.readFileSync(PATH); let pkg = JSON.parse(pkg_json) pkg.name = "nextgraph"; -pkg.description = "nodejs SDK of NextGraph"; +pkg.description = "nodeJS SDK of NextGraph"; fs.writeFileSync(PATH, JSON.stringify(pkg, null, 2), 'utf8'); fs.readFile(PATH_README, 'utf8', function (err,data) { diff --git a/ng-verifier/src/verifier.rs b/ng-verifier/src/verifier.rs index 7dd2f16..127a4a0 100644 --- a/ng-verifier/src/verifier.rs +++ b/ng-verifier/src/verifier.rs @@ -354,6 +354,7 @@ impl Verifier { )) } + #[allow(dead_code)] fn get_store_or_load(&mut self, store_repo: &StoreRepo) -> Arc { let overlay_id = store_repo.overlay_id_for_storage_purpose(); let block_storage = self @@ -411,6 +412,7 @@ impl Verifier { Ok(repo) } + #[allow(dead_code)] fn complete_site_store_already_inserted( &mut self, store_repo: StoreRepo, @@ -442,6 +444,7 @@ impl Verifier { Ok(()) } + #[allow(dead_code)] fn get_store(&self, store_repo: &StoreRepo) -> Result, VerifierError> { let overlay_id = store_repo.overlay_id_for_storage_purpose(); let store = self @@ -474,6 +477,7 @@ impl Verifier { repo_ref } + #[allow(dead_code)] fn add_store(&mut self, store: Arc) { let overlay_id = store.get_store_repo().overlay_id_for_storage_purpose(); if self.stores.contains_key(&overlay_id) { @@ -515,6 +519,7 @@ impl Verifier { .await } + #[allow(dead_code)] pub(crate) async fn new_event_with_repo( &mut self, commit: &Commit, @@ -2217,6 +2222,7 @@ impl Verifier { } /// returns the Repo and the last seq_num of the peer + #[allow(dead_code)] async fn new_repo_default<'a>( &'a mut self, creator: &UserId,