From 1794e10afaa26e53ec46f284c0aab1dfbe1ca42a Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Fri, 4 Aug 2023 15:10:40 +0200 Subject: [PATCH 01/48] added jammdb impl --- sdk/src/wallet/storage/adapter/jammdb.rs | 83 ++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 sdk/src/wallet/storage/adapter/jammdb.rs diff --git a/sdk/src/wallet/storage/adapter/jammdb.rs b/sdk/src/wallet/storage/adapter/jammdb.rs new file mode 100644 index 0000000000..d26b8ed9cc --- /dev/null +++ b/sdk/src/wallet/storage/adapter/jammdb.rs @@ -0,0 +1,83 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use super::StorageAdapter; +use jammdb::{OpenOptions, DB}; +use std::{ + fmt::Debug, + path::{Path, PathBuf}, + sync::Arc, +}; +use tokio::sync::Mutex; + +/// The storage id. +pub const STORAGE_ID: &str = "JammDB"; + +const BUCKET_NAME: &str = "storage"; + +impl Debug for JammdbStorageAdapter { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "JammDbStorageAdapter") + } +} + +/// Key value storage adapter. +pub struct JammdbStorageAdapter { + db: Arc>, +} + +impl JammdbStorageAdapter { + /// Initialises the storage adapter. + pub fn new(path: impl AsRef) -> crate::wallet::Result { + let mut db_path = PathBuf::from("./sdk-wallet.db"); + let dir_path = path.as_ref().to_string_lossy().to_string(); + let mut temp_path = PathBuf::from(dir_path); + if path.as_ref().is_dir() { + temp_path.push(db_path); + } + db_path = temp_path; + let db = OpenOptions::new().pagesize(4096).num_pages(32).open(db_path)?; + // create a default bucket + let tx = db.tx(true)?; + let bucket = tx.get_or_create_bucket(BUCKET_NAME)?; + bucket.put("INITIAL_KEY", "INIT_VALUE")?; // needs some initial value + tx.commit()?; + Ok(Self { + db: Arc::new(Mutex::new(db)), + }) + } +} + +#[async_trait::async_trait] +impl StorageAdapter for JammdbStorageAdapter { + type Error = crate::wallet::Error; + + async fn get_bytes(&self, key: &str) -> Result>, Self::Error> { + let db = self.db.lock().await; + let tx = db.tx(false)?; + let bucket = tx.get_bucket(BUCKET_NAME)?; + match bucket.get(key) { + Some(r) => Ok(Some(r.kv().value().into())), + None => Ok(None), + } + } + + async fn set_bytes(&self, key: &str, record: &[u8]) -> Result<(), Self::Error> { + let db = self.db.lock().await; + let tx = db.tx(true)?; + let bucket = tx.get_bucket(BUCKET_NAME)?; + bucket.put(key, record)?; + tx.commit()?; + Ok(()) + } + + async fn delete(&self, key: &str) -> crate::wallet::Result<()> { + let db = self.db.lock().await; + let tx = db.tx(true)?; + let bucket = tx.get_bucket(BUCKET_NAME)?; + + bucket.delete(key)?; + tx.commit()?; + Ok(()) + } +} From f810b43483f3904f35381b1197f1ca07ca21734b Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Fri, 4 Aug 2023 15:11:05 +0200 Subject: [PATCH 02/48] adjusted features --- sdk/src/wallet/storage/kind.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sdk/src/wallet/storage/kind.rs b/sdk/src/wallet/storage/kind.rs index 1714f6e09a..006d15c410 100644 --- a/sdk/src/wallet/storage/kind.rs +++ b/sdk/src/wallet/storage/kind.rs @@ -9,7 +9,12 @@ use serde::{Deserialize, Serialize}; pub enum StorageKind { /// RocksDB storage. #[cfg(feature = "rocksdb")] + #[cfg(not(feature = "jammdb"))] Rocksdb, + /// JammDB storage + #[cfg(feature = "jammdb")] + #[cfg(not(feature = "rocksdb"))] + Jammdb, /// Storage backed by a Map in memory. Memory, /// Wasm storage. @@ -20,10 +25,14 @@ pub enum StorageKind { impl Default for StorageKind { fn default() -> Self { #[cfg(feature = "rocksdb")] + #[cfg(not(feature = "jammdb"))] return Self::Rocksdb; + #[cfg(feature = "jammdb")] + #[cfg(not(feature = "rocksdb"))] + return Self::Jammdb; #[cfg(target_family = "wasm")] return Self::Wasm; - #[cfg(not(any(feature = "rocksdb", target_family = "wasm")))] + #[cfg(not(any(feature = "rocksdb", target_family = "wasm", feature = "jammdb")))] Self::Memory } } From 70bcf7acec68d938d417b18a8ba661781e493738 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Fri, 4 Aug 2023 15:11:50 +0200 Subject: [PATCH 03/48] adjusted features --- sdk/src/wallet/storage/constants.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sdk/src/wallet/storage/constants.rs b/sdk/src/wallet/storage/constants.rs index ae75d94881..909fb36a9d 100644 --- a/sdk/src/wallet/storage/constants.rs +++ b/sdk/src/wallet/storage/constants.rs @@ -4,14 +4,20 @@ /// The default storage path. pub const DEFAULT_STORAGE_PATH: &str = "./storage"; +/// The default RocksDB storage path. +#[cfg(feature = "jammdb")] +pub(crate) const JAMMDB_FOLDERNAME: &str = "walletdb"; + /// The default RocksDB storage path. #[cfg(feature = "rocksdb")] pub(crate) const ROCKSDB_FOLDERNAME: &str = "walletdb"; pub const fn default_storage_path() -> &'static str { - #[cfg(feature = "rocksdb")] + #[cfg(all(not(feature = "jammdb"), feature = "rocksdb"))] return ROCKSDB_FOLDERNAME; - #[cfg(not(feature = "rocksdb"))] + #[cfg(all(not(feature = "rocksdb"), feature = "jammdb"))] + return JAMMDB_FOLDERNAME; + #[cfg(all(not(feature = "rocksdb"), not(feature = "jammdb")))] DEFAULT_STORAGE_PATH } From ab775c980fa7ff322ca05677c494fb0e690d6ca0 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Fri, 4 Aug 2023 15:12:11 +0200 Subject: [PATCH 04/48] adjusted features --- sdk/src/wallet/storage/adapter/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sdk/src/wallet/storage/adapter/mod.rs b/sdk/src/wallet/storage/adapter/mod.rs index 06f7547e9a..bbc5fdb237 100644 --- a/sdk/src/wallet/storage/adapter/mod.rs +++ b/sdk/src/wallet/storage/adapter/mod.rs @@ -4,9 +4,16 @@ pub mod memory; /// RocksDB storage adapter. #[cfg(feature = "rocksdb")] +#[cfg(not(feature = "jammdb"))] #[cfg_attr(docsrs, doc(cfg(feature = "rocksdb")))] pub mod rocksdb; +/// JammDB storage adapter. +#[cfg(feature = "jammdb")] +#[cfg(not(feature = "rocksdb"))] +#[cfg_attr(docsrs, doc(cfg(feature = "jammdb")))] +pub mod jammdb; + use async_trait::async_trait; use crate::client::storage::StorageAdapter; From c4eba2d0909816f32ad309309d6089dd1f3c1981 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Fri, 4 Aug 2023 15:12:30 +0200 Subject: [PATCH 05/48] adjusted features and added impl --- sdk/src/wallet/core/builder.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sdk/src/wallet/core/builder.rs b/sdk/src/wallet/core/builder.rs index 967dc66b83..2cb3556245 100644 --- a/sdk/src/wallet/core/builder.rs +++ b/sdk/src/wallet/core/builder.rs @@ -15,7 +15,7 @@ use tokio::sync::RwLock; use super::operations::storage::SaveLoadWallet; #[cfg(feature = "events")] use crate::wallet::events::EventEmitter; -#[cfg(all(feature = "storage", not(feature = "rocksdb")))] +#[cfg(all(feature = "storage", not(feature = "rocksdb"), not(feature = "jammdb")))] use crate::wallet::storage::adapter::memory::Memory; #[cfg(feature = "storage")] use crate::wallet::{ @@ -134,10 +134,12 @@ where } } - #[cfg(all(feature = "rocksdb", feature = "storage"))] + #[cfg(all(not(feature = "jammdb"), feature = "rocksdb", feature = "storage"))] let storage = crate::wallet::storage::adapter::rocksdb::RocksdbStorageAdapter::new(storage_options.path.clone())?; - #[cfg(all(not(feature = "rocksdb"), feature = "storage"))] + #[cfg(all(not(feature = "rocksdb"), feature = "jammdb", feature = "storage"))] + let storage = crate::wallet::storage::adapter::jammdb::JammdbStorageAdapter::new(storage_options.path.clone())?; + #[cfg(all(not(feature = "rocksdb"), not(feature = "jammdb"), feature = "storage"))] let storage = Memory::default(); #[cfg(feature = "storage")] From cc434a0bbe4405e8080078ed6815e4bdfcefdeae Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Fri, 4 Aug 2023 15:12:58 +0200 Subject: [PATCH 06/48] added from impl --- sdk/src/wallet/error.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sdk/src/wallet/error.rs b/sdk/src/wallet/error.rs index 10dcc154c5..a4ef075bf3 100644 --- a/sdk/src/wallet/error.rs +++ b/sdk/src/wallet/error.rs @@ -189,3 +189,10 @@ impl From for Error { Self::Storage(error.to_string()) } } + +#[cfg(feature = "jammdb")] +impl From for Error { + fn from(error: jammdb::Error) -> Self { + Self::Storage(error.to_string()) + } +} From 2ee4870356c932982b87b1c5309974624ba242b1 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Fri, 4 Aug 2023 15:16:05 +0200 Subject: [PATCH 07/48] added deps and feature --- sdk/Cargo.toml | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index aa6dbabd8d..d2089bcbc6 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -82,6 +82,7 @@ reqwest = { version = "0.11.18", default-features = false, features = [ rocksdb = { version = "0.21.0", default-features = false, features = [ "lz4", ], optional = true } +jammdb = { version = "0.10.0", optional = true} rumqttc = { version = "0.22.0", default-features = false, features = [ "websocket", ], optional = true } @@ -146,6 +147,7 @@ mqtt = ["std", "regex", "rumqttc", "dep:once_cell"] participation = ["storage"] pow = ["std", "num_cpus", "iota-crypto/curl-p"] rand = ["dep:rand"] +jammdb = ["dep:jammdb", "storage"] rocksdb = ["dep:rocksdb", "storage"] serde = [ "serde_repr", @@ -228,37 +230,37 @@ required-features = ["client"] [[example]] name = "create_account" path = "examples/how_tos/accounts_and_addresses/create_account.rs" -required-features = ["rocksdb", "stronghold"] +required-features = ["jammdb", "stronghold"] [[example]] name = "list_accounts" path = "examples/how_tos/accounts_and_addresses/list_accounts.rs" -required-features = ["rocksdb", "stronghold"] +required-features = ["jammdb", "stronghold"] [[example]] name = "check_balance" path = "examples/how_tos/accounts_and_addresses/check_balance.rs" -required-features = ["rocksdb", "stronghold"] +required-features = ["jammdb", "stronghold"] [[example]] name = "list_addresses" path = "examples/how_tos/accounts_and_addresses/list_addresses.rs" -required-features = ["rocksdb", "stronghold"] +required-features = ["jammdb", "stronghold"] [[example]] name = "create_address" path = "examples/how_tos/accounts_and_addresses/create_address.rs" -required-features = ["rocksdb", "stronghold"] +required-features = ["jammdb", "stronghold"] [[example]] name = "list_transactions" path = "examples/how_tos/accounts_and_addresses/list_transactions.rs" -required-features = ["rocksdb", "stronghold"] +required-features = ["jammdb", "stronghold"] [[example]] name = "list_outputs" path = "examples/how_tos/accounts_and_addresses/list_outputs.rs" -required-features = ["rocksdb", "stronghold"] +required-features = ["jammdb", "stronghold"] [[example]] name = "consolidate_outputs" @@ -270,29 +272,29 @@ required-features = ["wallet", "stronghold"] [[example]] name = "request_funds" path = "examples/how_tos/simple_transaction/request_funds.rs" -required-features = ["rocksdb", "stronghold"] +required-features = ["jammdb", "stronghold"] [[example]] name = "simple_transaction" path = "examples/how_tos/simple_transaction/simple_transaction.rs" -required-features = ["rocksdb", "stronghold"] +required-features = ["jammdb", "stronghold"] # Advanced Transactions Examples [[example]] name = "send_micro_transaction" path = "examples/how_tos/advanced_transactions/send_micro_transaction.rs" -required-features = ["rocksdb", "stronghold"] +required-features = ["jammdb", "stronghold"] [[example]] name = "advanced_transaction" path = "examples/how_tos/advanced_transactions/advanced_transaction.rs" -required-features = ["rocksdb", "stronghold"] +required-features = ["jammdb", "stronghold"] [[example]] name = "claim_transaction" path = "examples/how_tos/advanced_transactions/claim_transaction.rs" -required-features = ["rocksdb", "stronghold"] +required-features = ["jammdb", "stronghold"] # NFT Collection Examples @@ -311,44 +313,44 @@ required-features = ["wallet", "stronghold"] [[example]] name = "create_native_token" path = "examples/how_tos/native_tokens/create.rs" -required-features = ["rocksdb", "stronghold"] +required-features = ["jammdb", "stronghold"] [[example]] name = "destroy_foundry" path = "examples/how_tos/native_tokens/destroy_foundry.rs" -required-features = ["rocksdb", "stronghold"] +required-features = ["jammdb", "stronghold"] [[example]] name = "burn_native_token" path = "examples/how_tos/native_tokens/burn.rs" -required-features = ["rocksdb", "stronghold"] +required-features = ["jammdb", "stronghold"] [[example]] name = "melt_native_token" path = "examples/how_tos/native_tokens/melt.rs" -required-features = ["rocksdb", "stronghold"] +required-features = ["jammdb", "stronghold"] [[example]] name = "mint_native_token" path = "examples/how_tos/native_tokens/mint.rs" -required-features = ["rocksdb", "stronghold"] +required-features = ["jammdb", "stronghold"] [[example]] name = "send_native_tokens" path = "examples/how_tos/native_tokens/send.rs" -required-features = ["rocksdb", "stronghold"] +required-features = ["jammdb", "stronghold"] # Alias wallet example [[example]] name = "alias_wallet_request_funds" path = "examples/how_tos/alias_wallet/request_funds.rs" -required-features = ["rocksdb", "stronghold"] +required-features = ["jammdb", "stronghold"] [[example]] name = "alias_wallet_transaction" path = "examples/how_tos/alias_wallet/transaction.rs" -required-features = ["rocksdb", "stronghold"] +required-features = ["jammdb", "stronghold"] [[example]] name = "create_alias" From 120aaa0302f14772f305b9bff542f728b6a2dbf4 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Fri, 4 Aug 2023 15:16:51 +0200 Subject: [PATCH 08/48] added feature --- bindings/core/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/bindings/core/Cargo.toml b/bindings/core/Cargo.toml index 09ea0380f0..74931afa50 100644 --- a/bindings/core/Cargo.toml +++ b/bindings/core/Cargo.toml @@ -32,5 +32,6 @@ ledger_nano = [ "iota-sdk/ledger_nano" ] mqtt = [ "iota-sdk/mqtt" ] participation = [ "iota-sdk/participation" ] rocksdb = [ "iota-sdk/rocksdb" ] +jammdb = ["iota-sdk/jammdb"] storage = [ "iota-sdk/storage" ] stronghold = [ "iota-sdk/stronghold" ] From a83a99cdcad5c730930f1e7797d1231230cf4244 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Fri, 4 Aug 2023 15:18:57 +0200 Subject: [PATCH 09/48] updated lock file --- Cargo.lock | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 6d4cc57bbc..91b22f40dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -385,6 +385,9 @@ name = "bytes" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +dependencies = [ + "serde", +] [[package]] name = "bzip2-sys" @@ -1118,6 +1121,16 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "funty" version = "2.0.0" @@ -1670,6 +1683,7 @@ dependencies = [ "iota_stronghold", "iterator-sorted", "itertools", + "jammdb", "lazy_static", "log", "num_cpus", @@ -1824,6 +1838,21 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +[[package]] +name = "jammdb" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4c90cda389cab46e91414e3fccce3fbad4b89a6e7b71c0957750c51f7345b74" +dependencies = [ + "bumpalo", + "bytes", + "fs2", + "libc", + "memmap2", + "page_size", + "sha3", +] + [[package]] name = "jobserver" version = "0.1.26" @@ -1856,6 +1885,15 @@ dependencies = [ "sha2", ] +[[package]] +name = "keccak" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" +dependencies = [ + "cpufeatures", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -2010,6 +2048,15 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "memmap2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" +dependencies = [ + "libc", +] + [[package]] name = "memoffset" version = "0.6.5" @@ -2218,6 +2265,16 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "page_size" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b7663cbd190cfd818d08efa8497f6cd383076688c49a391ef7c0d03cd12b561" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "parity-scale-codec" version = "3.6.4" @@ -3047,6 +3104,16 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest 0.10.7", + "keccak", +] + [[package]] name = "shell-words" version = "1.1.0" From 4938e4f90646a4036a3ae22d297c7009e83e0588 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Fri, 4 Aug 2023 15:20:19 +0200 Subject: [PATCH 10/48] reverted example deps --- sdk/Cargo.toml | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index d2089bcbc6..43eec27a6e 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -230,37 +230,37 @@ required-features = ["client"] [[example]] name = "create_account" path = "examples/how_tos/accounts_and_addresses/create_account.rs" -required-features = ["jammdb", "stronghold"] +required-features = ["rocksdb", "stronghold"] [[example]] name = "list_accounts" path = "examples/how_tos/accounts_and_addresses/list_accounts.rs" -required-features = ["jammdb", "stronghold"] +required-features = ["rocksdb", "stronghold"] [[example]] name = "check_balance" path = "examples/how_tos/accounts_and_addresses/check_balance.rs" -required-features = ["jammdb", "stronghold"] +required-features = ["rocksdb", "stronghold"] [[example]] name = "list_addresses" path = "examples/how_tos/accounts_and_addresses/list_addresses.rs" -required-features = ["jammdb", "stronghold"] +required-features = ["rocksdb", "stronghold"] [[example]] name = "create_address" path = "examples/how_tos/accounts_and_addresses/create_address.rs" -required-features = ["jammdb", "stronghold"] +required-features = ["rocksdb", "stronghold"] [[example]] name = "list_transactions" path = "examples/how_tos/accounts_and_addresses/list_transactions.rs" -required-features = ["jammdb", "stronghold"] +required-features = ["rocksdb", "stronghold"] [[example]] name = "list_outputs" path = "examples/how_tos/accounts_and_addresses/list_outputs.rs" -required-features = ["jammdb", "stronghold"] +required-features = ["rocksdb", "stronghold"] [[example]] name = "consolidate_outputs" @@ -272,29 +272,29 @@ required-features = ["wallet", "stronghold"] [[example]] name = "request_funds" path = "examples/how_tos/simple_transaction/request_funds.rs" -required-features = ["jammdb", "stronghold"] +required-features = ["rocksdb", "stronghold"] [[example]] name = "simple_transaction" path = "examples/how_tos/simple_transaction/simple_transaction.rs" -required-features = ["jammdb", "stronghold"] +required-features = ["rocksdb", "stronghold"] # Advanced Transactions Examples [[example]] name = "send_micro_transaction" path = "examples/how_tos/advanced_transactions/send_micro_transaction.rs" -required-features = ["jammdb", "stronghold"] +required-features = ["rocksdb", "stronghold"] [[example]] name = "advanced_transaction" path = "examples/how_tos/advanced_transactions/advanced_transaction.rs" -required-features = ["jammdb", "stronghold"] +required-features = ["rocksdb", "stronghold"] [[example]] name = "claim_transaction" path = "examples/how_tos/advanced_transactions/claim_transaction.rs" -required-features = ["jammdb", "stronghold"] +required-features = ["rocksdb", "stronghold"] # NFT Collection Examples @@ -313,44 +313,44 @@ required-features = ["wallet", "stronghold"] [[example]] name = "create_native_token" path = "examples/how_tos/native_tokens/create.rs" -required-features = ["jammdb", "stronghold"] +required-features = ["rocksdb", "stronghold"] [[example]] name = "destroy_foundry" path = "examples/how_tos/native_tokens/destroy_foundry.rs" -required-features = ["jammdb", "stronghold"] +required-features = ["rocksdb", "stronghold"] [[example]] name = "burn_native_token" path = "examples/how_tos/native_tokens/burn.rs" -required-features = ["jammdb", "stronghold"] +required-features = ["rocksdb", "stronghold"] [[example]] name = "melt_native_token" path = "examples/how_tos/native_tokens/melt.rs" -required-features = ["jammdb", "stronghold"] +required-features = ["rocksdb", "stronghold"] [[example]] name = "mint_native_token" path = "examples/how_tos/native_tokens/mint.rs" -required-features = ["jammdb", "stronghold"] +required-features = ["rocksdb", "stronghold"] [[example]] name = "send_native_tokens" path = "examples/how_tos/native_tokens/send.rs" -required-features = ["jammdb", "stronghold"] +required-features = ["rocksdb", "stronghold"] # Alias wallet example [[example]] name = "alias_wallet_request_funds" path = "examples/how_tos/alias_wallet/request_funds.rs" -required-features = ["jammdb", "stronghold"] +required-features = ["rocksdb", "stronghold"] [[example]] name = "alias_wallet_transaction" path = "examples/how_tos/alias_wallet/transaction.rs" -required-features = ["jammdb", "stronghold"] +required-features = ["rocksdb", "stronghold"] [[example]] name = "create_alias" From 340d434544fe40b553a0e62dc456b93b1a40e571 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Sun, 13 Aug 2023 18:21:41 +0530 Subject: [PATCH 11/48] sorted dependencies --- sdk/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index 43eec27a6e..eeebddc6e0 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -67,6 +67,7 @@ heck = { version = "0.4.1", default-features = false, optional = true } instant = { version = "0.1.12", default-features = false, optional = true } iota-ledger-nano = { version = "1.0.0-alpha.4", default-features = false, optional = true } iota_stronghold = { version = "2.0.0", default-features = false, optional = true } +jammdb = { version = "0.10.0", optional = true } log = { version = "0.4.19", default-features = false, optional = true } num_cpus = { version = "1.16.0", default-features = false, optional = true } once_cell = { version = "1.18.0", default-features = false, optional = true } @@ -82,7 +83,6 @@ reqwest = { version = "0.11.18", default-features = false, features = [ rocksdb = { version = "0.21.0", default-features = false, features = [ "lz4", ], optional = true } -jammdb = { version = "0.10.0", optional = true} rumqttc = { version = "0.22.0", default-features = false, features = [ "websocket", ], optional = true } From 5cbb595730bafea3414e31ac426cc839e885adc4 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Sun, 13 Aug 2023 18:34:02 +0530 Subject: [PATCH 12/48] corrected year in license --- sdk/src/wallet/storage/adapter/jammdb.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/src/wallet/storage/adapter/jammdb.rs b/sdk/src/wallet/storage/adapter/jammdb.rs index d26b8ed9cc..0a77c52cd0 100644 --- a/sdk/src/wallet/storage/adapter/jammdb.rs +++ b/sdk/src/wallet/storage/adapter/jammdb.rs @@ -1,4 +1,4 @@ -// Copyright 2020 IOTA Stiftung +// Copyright 2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 use super::StorageAdapter; From 61b5cf363cef8c86ca99194d03d84ae8f59ec4a6 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Sun, 13 Aug 2023 18:34:46 +0530 Subject: [PATCH 13/48] fixed case (supposedly) --- sdk/src/wallet/storage/adapter/jammdb.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/src/wallet/storage/adapter/jammdb.rs b/sdk/src/wallet/storage/adapter/jammdb.rs index 0a77c52cd0..515144b11b 100644 --- a/sdk/src/wallet/storage/adapter/jammdb.rs +++ b/sdk/src/wallet/storage/adapter/jammdb.rs @@ -13,7 +13,8 @@ use tokio::sync::Mutex; /// The storage id. pub const STORAGE_ID: &str = "JammDB"; -const BUCKET_NAME: &str = "storage"; +/// Default storage name +pub const BUCKET_NAME: &str = "Storage"; impl Debug for JammdbStorageAdapter { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { From 44ca624e0188f533aa1a6b8bfbe7b6bcb0eaa2b8 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Sun, 13 Aug 2023 18:34:58 +0530 Subject: [PATCH 14/48] fixed case (supposedly) --- sdk/src/wallet/storage/adapter/jammdb.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/src/wallet/storage/adapter/jammdb.rs b/sdk/src/wallet/storage/adapter/jammdb.rs index 515144b11b..c9ce49cde3 100644 --- a/sdk/src/wallet/storage/adapter/jammdb.rs +++ b/sdk/src/wallet/storage/adapter/jammdb.rs @@ -18,11 +18,12 @@ pub const BUCKET_NAME: &str = "Storage"; impl Debug for JammdbStorageAdapter { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "JammDbStorageAdapter") + write!(f, "JammdbStorageAdapter") } } /// Key value storage adapter. +#[derive(Clone)] pub struct JammdbStorageAdapter { db: Arc>, } From de7d6ecf14ebb244b41739d87dabc903aa1cfd86 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Sun, 13 Aug 2023 18:35:30 +0530 Subject: [PATCH 15/48] improved impl --- sdk/src/wallet/storage/adapter/jammdb.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sdk/src/wallet/storage/adapter/jammdb.rs b/sdk/src/wallet/storage/adapter/jammdb.rs index c9ce49cde3..09e830fd71 100644 --- a/sdk/src/wallet/storage/adapter/jammdb.rs +++ b/sdk/src/wallet/storage/adapter/jammdb.rs @@ -31,13 +31,10 @@ pub struct JammdbStorageAdapter { impl JammdbStorageAdapter { /// Initialises the storage adapter. pub fn new(path: impl AsRef) -> crate::wallet::Result { - let mut db_path = PathBuf::from("./sdk-wallet.db"); - let dir_path = path.as_ref().to_string_lossy().to_string(); - let mut temp_path = PathBuf::from(dir_path); - if path.as_ref().is_dir() { - temp_path.push(db_path); + let mut db_path = path.as_ref().to_owned(); + if db_path.is_dir() { + db_path.push("sdk-wallet.db"); } - db_path = temp_path; let db = OpenOptions::new().pagesize(4096).num_pages(32).open(db_path)?; // create a default bucket let tx = db.tx(true)?; @@ -62,6 +59,7 @@ impl StorageAdapter for JammdbStorageAdapter { Some(r) => Ok(Some(r.kv().value().into())), None => Ok(None), } + Ok(bucket.get(key).map(|r| r.kv().value().into())) } async fn set_bytes(&self, key: &str, record: &[u8]) -> Result<(), Self::Error> { From 975be8007498c09be936b80fc20648572335f86a Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Sun, 13 Aug 2023 18:36:25 +0530 Subject: [PATCH 16/48] feature flag fixed --- sdk/src/wallet/storage/adapter/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/src/wallet/storage/adapter/mod.rs b/sdk/src/wallet/storage/adapter/mod.rs index bbc5fdb237..7a1e0e77f7 100644 --- a/sdk/src/wallet/storage/adapter/mod.rs +++ b/sdk/src/wallet/storage/adapter/mod.rs @@ -4,7 +4,6 @@ pub mod memory; /// RocksDB storage adapter. #[cfg(feature = "rocksdb")] -#[cfg(not(feature = "jammdb"))] #[cfg_attr(docsrs, doc(cfg(feature = "rocksdb")))] pub mod rocksdb; From 2290f76ec96ef96927ee6389e7fa350f5bc582c9 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Sun, 13 Aug 2023 18:38:17 +0530 Subject: [PATCH 17/48] feature flag fixed --- sdk/src/wallet/core/builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/src/wallet/core/builder.rs b/sdk/src/wallet/core/builder.rs index 2cb3556245..e7f2bd95f3 100644 --- a/sdk/src/wallet/core/builder.rs +++ b/sdk/src/wallet/core/builder.rs @@ -134,7 +134,7 @@ where } } - #[cfg(all(not(feature = "jammdb"), feature = "rocksdb", feature = "storage"))] + #[cfg(all(feature = "rocksdb", feature = "storage"))] let storage = crate::wallet::storage::adapter::rocksdb::RocksdbStorageAdapter::new(storage_options.path.clone())?; #[cfg(all(not(feature = "rocksdb"), feature = "jammdb", feature = "storage"))] From c8ae9a3bc1b08b1b6b5945d981cb939e69780152 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Sun, 13 Aug 2023 18:39:19 +0530 Subject: [PATCH 18/48] feature flag fixed --- sdk/src/wallet/storage/constants.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/src/wallet/storage/constants.rs b/sdk/src/wallet/storage/constants.rs index 909fb36a9d..a3ae017b10 100644 --- a/sdk/src/wallet/storage/constants.rs +++ b/sdk/src/wallet/storage/constants.rs @@ -4,8 +4,8 @@ /// The default storage path. pub const DEFAULT_STORAGE_PATH: &str = "./storage"; -/// The default RocksDB storage path. -#[cfg(feature = "jammdb")] +/// The default jammDB storage path. +#[cfg(all(not(feature = "rocksdb"), feature = "jammdb"))] pub(crate) const JAMMDB_FOLDERNAME: &str = "walletdb"; /// The default RocksDB storage path. @@ -13,7 +13,7 @@ pub(crate) const JAMMDB_FOLDERNAME: &str = "walletdb"; pub(crate) const ROCKSDB_FOLDERNAME: &str = "walletdb"; pub const fn default_storage_path() -> &'static str { - #[cfg(all(not(feature = "jammdb"), feature = "rocksdb"))] + #[cfg(all(feature = "rocksdb"))] return ROCKSDB_FOLDERNAME; #[cfg(all(not(feature = "rocksdb"), feature = "jammdb"))] return JAMMDB_FOLDERNAME; From 2031f244eb8cca6602bbc59627c4facb4f031438 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Sun, 13 Aug 2023 18:41:02 +0530 Subject: [PATCH 19/48] feature flag fixed --- sdk/src/wallet/storage/kind.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/sdk/src/wallet/storage/kind.rs b/sdk/src/wallet/storage/kind.rs index 006d15c410..717d869596 100644 --- a/sdk/src/wallet/storage/kind.rs +++ b/sdk/src/wallet/storage/kind.rs @@ -9,7 +9,6 @@ use serde::{Deserialize, Serialize}; pub enum StorageKind { /// RocksDB storage. #[cfg(feature = "rocksdb")] - #[cfg(not(feature = "jammdb"))] Rocksdb, /// JammDB storage #[cfg(feature = "jammdb")] @@ -25,7 +24,6 @@ pub enum StorageKind { impl Default for StorageKind { fn default() -> Self { #[cfg(feature = "rocksdb")] - #[cfg(not(feature = "jammdb"))] return Self::Rocksdb; #[cfg(feature = "jammdb")] #[cfg(not(feature = "rocksdb"))] From f9f9b3c9e2e238222c1eddcca84e197c16b090a9 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Sun, 13 Aug 2023 18:52:16 +0530 Subject: [PATCH 20/48] deps sorted --- sdk/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index eeebddc6e0..c5291fb48a 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -143,11 +143,11 @@ default = ["client", "wallet", "tls"] events = [] ledger_nano = ["iota-ledger-nano"] +jammdb = ["dep:jammdb", "storage"] mqtt = ["std", "regex", "rumqttc", "dep:once_cell"] participation = ["storage"] pow = ["std", "num_cpus", "iota-crypto/curl-p"] rand = ["dep:rand"] -jammdb = ["dep:jammdb", "storage"] rocksdb = ["dep:rocksdb", "storage"] serde = [ "serde_repr", From 61dc915f499515b2ff3010cc8bbcaf97e2f348a2 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Sun, 13 Aug 2023 18:54:56 +0530 Subject: [PATCH 21/48] deps sorted --- bindings/core/Cargo.toml | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/bindings/core/Cargo.toml b/bindings/core/Cargo.toml index 74931afa50..072a397d3e 100644 --- a/bindings/core/Cargo.toml +++ b/bindings/core/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "iota-sdk-bindings-core" version = "0.1.0" -authors = [ "IOTA Stiftung" ] +authors = ["IOTA Stiftung"] edition = "2021" homepage = "https://iota.org" description = "Bindings core for the IOTA SDK" @@ -9,13 +9,19 @@ license = "Apache-2.0" publish = false [dependencies] -iota-sdk = { path = "../../sdk", default-features = false, features = [ "wallet", "tls" ] } +iota-sdk = { path = "../../sdk", default-features = false, features = [ + "wallet", + "tls", +] } -backtrace = { version = "0.3.68", default-features = false, features = [ "std" ] } +backtrace = { version = "0.3.68", default-features = false, features = ["std"] } derivative = { version = "2.2.0", default-features = false } fern-logger = { version = "0.5.0", default-features = false } -futures = { version = "0.3.28", default-features = false } -iota-crypto = { version = "0.23.0", default-features = false, features = [ "slip10", "bip44" ] } +futures = { version = "0.3.28", default-features = false } +iota-crypto = { version = "0.23.0", default-features = false, features = [ + "slip10", + "bip44", +] } log = { version = "0.4.19", default-features = false } packable = { version = "0.8.1", default-features = false } prefix-hex = { version = "0.7.1", default-features = false } @@ -27,11 +33,11 @@ tokio = { version = "1.29.1", default-features = false } zeroize = { version = "1.6.0", default-features = false } [features] -events = [ "iota-sdk/events" ] -ledger_nano = [ "iota-sdk/ledger_nano" ] -mqtt = [ "iota-sdk/mqtt" ] -participation = [ "iota-sdk/participation" ] -rocksdb = [ "iota-sdk/rocksdb" ] +events = ["iota-sdk/events"] jammdb = ["iota-sdk/jammdb"] -storage = [ "iota-sdk/storage" ] -stronghold = [ "iota-sdk/stronghold" ] +ledger_nano = ["iota-sdk/ledger_nano"] +mqtt = ["iota-sdk/mqtt"] +participation = ["iota-sdk/participation"] +rocksdb = ["iota-sdk/rocksdb"] +storage = ["iota-sdk/storage"] +stronghold = ["iota-sdk/stronghold"] From cc2bee58d72a3e6ebff0d974af15a0747196c396 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Sun, 13 Aug 2023 18:58:21 +0530 Subject: [PATCH 22/48] reverted changes due to autofmt --- bindings/core/Cargo.toml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/bindings/core/Cargo.toml b/bindings/core/Cargo.toml index 072a397d3e..e6f5aeb3fd 100644 --- a/bindings/core/Cargo.toml +++ b/bindings/core/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "iota-sdk-bindings-core" version = "0.1.0" -authors = ["IOTA Stiftung"] +authors = [ "IOTA Stiftung" ] edition = "2021" homepage = "https://iota.org" description = "Bindings core for the IOTA SDK" @@ -9,19 +9,11 @@ license = "Apache-2.0" publish = false [dependencies] -iota-sdk = { path = "../../sdk", default-features = false, features = [ - "wallet", - "tls", -] } - -backtrace = { version = "0.3.68", default-features = false, features = ["std"] } +iota-sdk = { path = "../../sdk", default-features = false, features = [ "wallet", "tls" ] } +backtrace = { version = "0.3.68", default-features = false, features = [ "std" ] } derivative = { version = "2.2.0", default-features = false } fern-logger = { version = "0.5.0", default-features = false } -futures = { version = "0.3.28", default-features = false } -iota-crypto = { version = "0.23.0", default-features = false, features = [ - "slip10", - "bip44", -] } +iota-crypto = { version = "0.23.0", default-features = false, features = [ "slip10", "bip44" ] } log = { version = "0.4.19", default-features = false } packable = { version = "0.8.1", default-features = false } prefix-hex = { version = "0.7.1", default-features = false } From 25bd57e15de768f9c1bb9a42dce838cc2f3cd7cb Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Sun, 13 Aug 2023 18:59:19 +0530 Subject: [PATCH 23/48] reverted changes due to autofmt --- bindings/core/Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bindings/core/Cargo.toml b/bindings/core/Cargo.toml index e6f5aeb3fd..ba583829c6 100644 --- a/bindings/core/Cargo.toml +++ b/bindings/core/Cargo.toml @@ -10,9 +10,11 @@ publish = false [dependencies] iota-sdk = { path = "../../sdk", default-features = false, features = [ "wallet", "tls" ] } + backtrace = { version = "0.3.68", default-features = false, features = [ "std" ] } derivative = { version = "2.2.0", default-features = false } fern-logger = { version = "0.5.0", default-features = false } +futures = { version = "0.3.28", default-features = false } iota-crypto = { version = "0.23.0", default-features = false, features = [ "slip10", "bip44" ] } log = { version = "0.4.19", default-features = false } packable = { version = "0.8.1", default-features = false } From a3d34ab256376881a7c50fcda3791f2b0b43192d Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Sun, 13 Aug 2023 19:02:15 +0530 Subject: [PATCH 24/48] removed old impl --- sdk/src/wallet/storage/adapter/jammdb.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sdk/src/wallet/storage/adapter/jammdb.rs b/sdk/src/wallet/storage/adapter/jammdb.rs index 09e830fd71..0f2d86a5aa 100644 --- a/sdk/src/wallet/storage/adapter/jammdb.rs +++ b/sdk/src/wallet/storage/adapter/jammdb.rs @@ -55,10 +55,6 @@ impl StorageAdapter for JammdbStorageAdapter { let db = self.db.lock().await; let tx = db.tx(false)?; let bucket = tx.get_bucket(BUCKET_NAME)?; - match bucket.get(key) { - Some(r) => Ok(Some(r.kv().value().into())), - None => Ok(None), - } Ok(bucket.get(key).map(|r| r.kv().value().into())) } From 793b83ac5600e56fc1e2e5399a8f0a09b0137c05 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Sun, 13 Aug 2023 19:03:43 +0530 Subject: [PATCH 25/48] reverted cfg for rocksdb --- sdk/src/wallet/storage/constants.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/src/wallet/storage/constants.rs b/sdk/src/wallet/storage/constants.rs index a3ae017b10..5807961291 100644 --- a/sdk/src/wallet/storage/constants.rs +++ b/sdk/src/wallet/storage/constants.rs @@ -13,7 +13,7 @@ pub(crate) const JAMMDB_FOLDERNAME: &str = "walletdb"; pub(crate) const ROCKSDB_FOLDERNAME: &str = "walletdb"; pub const fn default_storage_path() -> &'static str { - #[cfg(all(feature = "rocksdb"))] + #[cfg(feature = "rocksdb")] return ROCKSDB_FOLDERNAME; #[cfg(all(not(feature = "rocksdb"), feature = "jammdb"))] return JAMMDB_FOLDERNAME; From 2213d8525a9b9d6c61feb81512b86d5dfffd2d83 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Mon, 14 Aug 2023 15:58:29 +0530 Subject: [PATCH 26/48] ran cargo fmt --- sdk/src/wallet/storage/adapter/jammdb.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sdk/src/wallet/storage/adapter/jammdb.rs b/sdk/src/wallet/storage/adapter/jammdb.rs index 0f2d86a5aa..726afb1a1d 100644 --- a/sdk/src/wallet/storage/adapter/jammdb.rs +++ b/sdk/src/wallet/storage/adapter/jammdb.rs @@ -1,15 +1,17 @@ // Copyright 2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use super::StorageAdapter; -use jammdb::{OpenOptions, DB}; use std::{ fmt::Debug, path::{Path, PathBuf}, sync::Arc, }; + +use jammdb::{OpenOptions, DB}; use tokio::sync::Mutex; +use super::StorageAdapter; + /// The storage id. pub const STORAGE_ID: &str = "JammDB"; From 888c8e8ed9452cd7c073df0ae777e59d16d82fb4 Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar Date: Mon, 14 Aug 2023 16:15:10 +0530 Subject: [PATCH 27/48] Update sdk/Cargo.toml Co-authored-by: Thoralf-M <46689931+Thoralf-M@users.noreply.github.com> --- sdk/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index c5291fb48a..01bb5758dd 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -67,7 +67,7 @@ heck = { version = "0.4.1", default-features = false, optional = true } instant = { version = "0.1.12", default-features = false, optional = true } iota-ledger-nano = { version = "1.0.0-alpha.4", default-features = false, optional = true } iota_stronghold = { version = "2.0.0", default-features = false, optional = true } -jammdb = { version = "0.10.0", optional = true } +jammdb = { version = "0.10.0", default-features = false, optional = true } log = { version = "0.4.19", default-features = false, optional = true } num_cpus = { version = "1.16.0", default-features = false, optional = true } once_cell = { version = "1.18.0", default-features = false, optional = true } From 7d5ba4599d64d6fe388c79db23b4bd95c99b7899 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Tue, 22 Aug 2023 13:02:26 +0200 Subject: [PATCH 28/48] improved with cfg_if --- sdk/src/wallet/storage/constants.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/sdk/src/wallet/storage/constants.rs b/sdk/src/wallet/storage/constants.rs index 5807961291..32d1f1cbef 100644 --- a/sdk/src/wallet/storage/constants.rs +++ b/sdk/src/wallet/storage/constants.rs @@ -5,20 +5,25 @@ pub const DEFAULT_STORAGE_PATH: &str = "./storage"; /// The default jammDB storage path. -#[cfg(all(not(feature = "rocksdb"), feature = "jammdb"))] -pub(crate) const JAMMDB_FOLDERNAME: &str = "walletdb"; +#[cfg(feature = "jammdb")] +pub const JAMMDB_FOLDERNAME: &str = "walletdb"; /// The default RocksDB storage path. #[cfg(feature = "rocksdb")] pub(crate) const ROCKSDB_FOLDERNAME: &str = "walletdb"; pub const fn default_storage_path() -> &'static str { - #[cfg(feature = "rocksdb")] - return ROCKSDB_FOLDERNAME; - #[cfg(all(not(feature = "rocksdb"), feature = "jammdb"))] - return JAMMDB_FOLDERNAME; - #[cfg(all(not(feature = "rocksdb"), not(feature = "jammdb")))] - DEFAULT_STORAGE_PATH + cfg_if::cfg_if!{ + if #[cfg(feature = "rocksdb")]{ + return ROCKSDB_FOLDERNAME; + } + else if #[cfg(feature = "jammdb")] { + return JAMMDB_FOLDERNAME; + } + else { + DEFAULT_STORAGE_PATH + } + } } pub(crate) const WALLET_INDEXATION_KEY: &str = "iota-wallet-account-manager"; From 24859cd1f19cdc9a91f5c49a8a9185c468129356 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Tue, 22 Aug 2023 13:02:39 +0200 Subject: [PATCH 29/48] updated deps --- Cargo.lock | 1 + sdk/Cargo.toml | 1 + 2 files changed, 2 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 91b22f40dd..5ee0d392fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1665,6 +1665,7 @@ dependencies = [ "bech32 0.9.1", "bitflags 2.3.3", "bytemuck", + "cfg-if", "derive_builder", "derive_more", "dotenvy", diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index 01bb5758dd..f6ff6921b9 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -21,6 +21,7 @@ rustdoc-args = ["--cfg", "docsrs"] bech32 = { version = "0.9.1", default-features = false } bitflags = { version = "2.3.3", default-features = false } bytemuck = { version = "1.13.1", default-features = false } +cfg-if={version= "1.0.0", default-features = false} derive_more = { version = "0.99.17", default-features = false, features = [ "from", "as_ref", From 81ffe1766f922f0eb949c1dfcbefe59a3e46af91 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Tue, 22 Aug 2023 16:30:53 +0200 Subject: [PATCH 30/48] fixed spacing --- sdk/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index f6ff6921b9..becefdafd1 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -21,7 +21,7 @@ rustdoc-args = ["--cfg", "docsrs"] bech32 = { version = "0.9.1", default-features = false } bitflags = { version = "2.3.3", default-features = false } bytemuck = { version = "1.13.1", default-features = false } -cfg-if={version= "1.0.0", default-features = false} +cfg-if = { version = "1.0.0", default-features = false } derive_more = { version = "0.99.17", default-features = false, features = [ "from", "as_ref", From 84dc59f22e4055bf9f8bb79e370fbdc2da96afe7 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Wed, 23 Aug 2023 10:06:49 +0200 Subject: [PATCH 31/48] removed return --- sdk/src/wallet/storage/constants.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/src/wallet/storage/constants.rs b/sdk/src/wallet/storage/constants.rs index 32d1f1cbef..ae57ee708a 100644 --- a/sdk/src/wallet/storage/constants.rs +++ b/sdk/src/wallet/storage/constants.rs @@ -13,17 +13,17 @@ pub const JAMMDB_FOLDERNAME: &str = "walletdb"; pub(crate) const ROCKSDB_FOLDERNAME: &str = "walletdb"; pub const fn default_storage_path() -> &'static str { - cfg_if::cfg_if!{ + cfg_if::cfg_if! { if #[cfg(feature = "rocksdb")]{ - return ROCKSDB_FOLDERNAME; + ROCKSDB_FOLDERNAME } else if #[cfg(feature = "jammdb")] { - return JAMMDB_FOLDERNAME; + JAMMDB_FOLDERNAME } else { DEFAULT_STORAGE_PATH } - } + } } pub(crate) const WALLET_INDEXATION_KEY: &str = "iota-wallet-account-manager"; From ec42d30e70bf368e45d210f906cbabd351d5abc1 Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar Date: Thu, 24 Aug 2023 14:47:54 +0200 Subject: [PATCH 32/48] Update sdk/src/wallet/storage/kind.rs Co-authored-by: Alexandcoats --- sdk/src/wallet/storage/kind.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/src/wallet/storage/kind.rs b/sdk/src/wallet/storage/kind.rs index 717d869596..d6a9dfbc0d 100644 --- a/sdk/src/wallet/storage/kind.rs +++ b/sdk/src/wallet/storage/kind.rs @@ -12,7 +12,6 @@ pub enum StorageKind { Rocksdb, /// JammDB storage #[cfg(feature = "jammdb")] - #[cfg(not(feature = "rocksdb"))] Jammdb, /// Storage backed by a Map in memory. Memory, From 2a698ca3489ac4c88a151845b1d29af8488d0f79 Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar Date: Thu, 24 Aug 2023 16:25:04 +0200 Subject: [PATCH 33/48] Update sdk/src/wallet/storage/adapter/mod.rs Co-authored-by: Alexandcoats --- sdk/src/wallet/storage/adapter/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/src/wallet/storage/adapter/mod.rs b/sdk/src/wallet/storage/adapter/mod.rs index 7a1e0e77f7..de98083e79 100644 --- a/sdk/src/wallet/storage/adapter/mod.rs +++ b/sdk/src/wallet/storage/adapter/mod.rs @@ -9,7 +9,6 @@ pub mod rocksdb; /// JammDB storage adapter. #[cfg(feature = "jammdb")] -#[cfg(not(feature = "rocksdb"))] #[cfg_attr(docsrs, doc(cfg(feature = "jammdb")))] pub mod jammdb; From 245d85c067c6e47ce4666aa7c9b227e8aab0cd05 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Thu, 24 Aug 2023 16:40:16 +0200 Subject: [PATCH 34/48] added cfg if --- sdk/src/wallet/core/builder.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/sdk/src/wallet/core/builder.rs b/sdk/src/wallet/core/builder.rs index e7f2bd95f3..46b182d6a2 100644 --- a/sdk/src/wallet/core/builder.rs +++ b/sdk/src/wallet/core/builder.rs @@ -15,8 +15,6 @@ use tokio::sync::RwLock; use super::operations::storage::SaveLoadWallet; #[cfg(feature = "events")] use crate::wallet::events::EventEmitter; -#[cfg(all(feature = "storage", not(feature = "rocksdb"), not(feature = "jammdb")))] -use crate::wallet::storage::adapter::memory::Memory; #[cfg(feature = "storage")] use crate::wallet::{ account::AccountDetails, @@ -134,13 +132,19 @@ where } } - #[cfg(all(feature = "rocksdb", feature = "storage"))] - let storage = - crate::wallet::storage::adapter::rocksdb::RocksdbStorageAdapter::new(storage_options.path.clone())?; - #[cfg(all(not(feature = "rocksdb"), feature = "jammdb", feature = "storage"))] - let storage = crate::wallet::storage::adapter::jammdb::JammdbStorageAdapter::new(storage_options.path.clone())?; - #[cfg(all(not(feature = "rocksdb"), not(feature = "jammdb"), feature = "storage"))] - let storage = Memory::default(); + #[cfg(feature = "storage")] + cfg_if::cfg_if!( + if #[cfg(feature = "rocksdb")] { + let storage = + crate::wallet::storage::adapter::rocksdb::RocksdbStorageAdapter::new(storage_options.path.clone())?; + } + else if #[cfg(feature = "jammdb")]{ + let storage = crate::wallet::storage::adapter::jammdb::JammdbStorageAdapter::new(storage_options.path.clone())?; + } + else { + let storage = crate::wallet::storage::adapter::memory::Memory::default(); + } + ); #[cfg(feature = "storage")] let mut storage_manager = StorageManager::new(storage, storage_options.encryption_key.clone()).await?; From 25d844dec3594b0c73b9dca2a33078e6618f9943 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Thu, 24 Aug 2023 16:40:37 +0200 Subject: [PATCH 35/48] removed unused dep --- sdk/src/wallet/storage/adapter/jammdb.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/sdk/src/wallet/storage/adapter/jammdb.rs b/sdk/src/wallet/storage/adapter/jammdb.rs index 726afb1a1d..08df8354a6 100644 --- a/sdk/src/wallet/storage/adapter/jammdb.rs +++ b/sdk/src/wallet/storage/adapter/jammdb.rs @@ -1,11 +1,7 @@ // Copyright 2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use std::{ - fmt::Debug, - path::{Path, PathBuf}, - sync::Arc, -}; +use std::{fmt::Debug, path::Path, sync::Arc}; use jammdb::{OpenOptions, DB}; use tokio::sync::Mutex; From b16d9555b3c6391c1c2e5669ae7af30ec14c3d49 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Thu, 24 Aug 2023 16:40:52 +0200 Subject: [PATCH 36/48] added cfg if --- sdk/src/wallet/storage/kind.rs | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/sdk/src/wallet/storage/kind.rs b/sdk/src/wallet/storage/kind.rs index d6a9dfbc0d..9c3fb0f2b7 100644 --- a/sdk/src/wallet/storage/kind.rs +++ b/sdk/src/wallet/storage/kind.rs @@ -22,14 +22,25 @@ pub enum StorageKind { impl Default for StorageKind { fn default() -> Self { - #[cfg(feature = "rocksdb")] - return Self::Rocksdb; - #[cfg(feature = "jammdb")] - #[cfg(not(feature = "rocksdb"))] - return Self::Jammdb; - #[cfg(target_family = "wasm")] - return Self::Wasm; - #[cfg(not(any(feature = "rocksdb", target_family = "wasm", feature = "jammdb")))] - Self::Memory + cfg_if::cfg_if!( + if #[cfg(feature="rocksdb")]{ + return Self::Rocksdb; + } else if #[cfg(feature="jammdb")] { + return Self::Jammdb; + } + else if #[cfg(target_family="wasm")]{ + return Self::Wasm; + }else{ + return Self::Memory; + } + ); + // #[cfg(feature = "rocksdb")] + // return #[cfg(feature = "jammdb")] + // #[cfg(not(feature = "rocksdb"))] + // return Self::Jammdb; + // #[cfg(target_family = "wasm")] + // return Self::Wasm; + // #[cfg(not(any(feature = "rocksdb", target_family = "wasm", feature = "jammdb")))] + // Self::Memory } } From bd240ab5d6c60393d9ea861aaeac23c64edcdb22 Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar Date: Fri, 25 Aug 2023 08:47:22 +0200 Subject: [PATCH 37/48] Update sdk/src/wallet/storage/kind.rs Co-authored-by: Alexandcoats --- sdk/src/wallet/storage/kind.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/sdk/src/wallet/storage/kind.rs b/sdk/src/wallet/storage/kind.rs index 9c3fb0f2b7..ee79ac8a7b 100644 --- a/sdk/src/wallet/storage/kind.rs +++ b/sdk/src/wallet/storage/kind.rs @@ -34,13 +34,5 @@ impl Default for StorageKind { return Self::Memory; } ); - // #[cfg(feature = "rocksdb")] - // return #[cfg(feature = "jammdb")] - // #[cfg(not(feature = "rocksdb"))] - // return Self::Jammdb; - // #[cfg(target_family = "wasm")] - // return Self::Wasm; - // #[cfg(not(any(feature = "rocksdb", target_family = "wasm", feature = "jammdb")))] - // Self::Memory } } From 1434b9a0e70f77361c1bd1b704220ac45f748a57 Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar Date: Fri, 25 Aug 2023 08:47:38 +0200 Subject: [PATCH 38/48] Update sdk/src/wallet/storage/constants.rs Co-authored-by: Alexandcoats --- sdk/src/wallet/storage/constants.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sdk/src/wallet/storage/constants.rs b/sdk/src/wallet/storage/constants.rs index ae57ee708a..8f3256ca12 100644 --- a/sdk/src/wallet/storage/constants.rs +++ b/sdk/src/wallet/storage/constants.rs @@ -14,13 +14,11 @@ pub(crate) const ROCKSDB_FOLDERNAME: &str = "walletdb"; pub const fn default_storage_path() -> &'static str { cfg_if::cfg_if! { - if #[cfg(feature = "rocksdb")]{ + if #[cfg(feature = "rocksdb")] { ROCKSDB_FOLDERNAME - } - else if #[cfg(feature = "jammdb")] { + } else if #[cfg(feature = "jammdb")] { JAMMDB_FOLDERNAME - } - else { + } else { DEFAULT_STORAGE_PATH } } From 301c499462a3f4e9adda6b7ab3b135d2c0c57cb0 Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar Date: Fri, 25 Aug 2023 08:48:11 +0200 Subject: [PATCH 39/48] Update sdk/src/wallet/core/builder.rs Co-authored-by: Alexandcoats --- sdk/src/wallet/core/builder.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/sdk/src/wallet/core/builder.rs b/sdk/src/wallet/core/builder.rs index 46b182d6a2..f2c1592c53 100644 --- a/sdk/src/wallet/core/builder.rs +++ b/sdk/src/wallet/core/builder.rs @@ -133,16 +133,13 @@ where } #[cfg(feature = "storage")] - cfg_if::cfg_if!( + let storage = cfg_if::cfg_if!( if #[cfg(feature = "rocksdb")] { - let storage = - crate::wallet::storage::adapter::rocksdb::RocksdbStorageAdapter::new(storage_options.path.clone())?; - } - else if #[cfg(feature = "jammdb")]{ - let storage = crate::wallet::storage::adapter::jammdb::JammdbStorageAdapter::new(storage_options.path.clone())?; - } - else { - let storage = crate::wallet::storage::adapter::memory::Memory::default(); + crate::wallet::storage::adapter::rocksdb::RocksdbStorageAdapter::new(storage_options.path.clone())? + } else if #[cfg(feature = "jammdb")] { + crate::wallet::storage::adapter::jammdb::JammdbStorageAdapter::new(storage_options.path.clone())? + } else { + crate::wallet::storage::adapter::memory::Memory::default() } ); From 789f6d7c453671bfd1d5f0d4fa639bdde1d6a30d Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar Date: Fri, 25 Aug 2023 08:49:01 +0200 Subject: [PATCH 40/48] Update sdk/src/wallet/storage/kind.rs Co-authored-by: Alexandcoats --- sdk/src/wallet/storage/kind.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/sdk/src/wallet/storage/kind.rs b/sdk/src/wallet/storage/kind.rs index ee79ac8a7b..c2384c388f 100644 --- a/sdk/src/wallet/storage/kind.rs +++ b/sdk/src/wallet/storage/kind.rs @@ -23,15 +23,14 @@ pub enum StorageKind { impl Default for StorageKind { fn default() -> Self { cfg_if::cfg_if!( - if #[cfg(feature="rocksdb")]{ - return Self::Rocksdb; - } else if #[cfg(feature="jammdb")] { - return Self::Jammdb; - } - else if #[cfg(target_family="wasm")]{ - return Self::Wasm; - }else{ - return Self::Memory; + if #[cfg(feature = "rocksdb")] { + Self::Rocksdb + } else if #[cfg(feature = "jammdb")] { + Self::Jammdb + } else if #[cfg(target_family = "wasm")] { + Self::Wasm + } else { + Self::Memory } ); } From c02dfb056b6b07a527813cbe6bb3443a57b90ff7 Mon Sep 17 00:00:00 2001 From: Alexandcoats Date: Fri, 25 Aug 2023 11:07:16 -0400 Subject: [PATCH 41/48] Update sdk/src/wallet/core/builder.rs --- sdk/src/wallet/core/builder.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sdk/src/wallet/core/builder.rs b/sdk/src/wallet/core/builder.rs index f2c1592c53..53b2cebc0d 100644 --- a/sdk/src/wallet/core/builder.rs +++ b/sdk/src/wallet/core/builder.rs @@ -133,15 +133,15 @@ where } #[cfg(feature = "storage")] - let storage = cfg_if::cfg_if!( + cfg_if::cfg_if!( if #[cfg(feature = "rocksdb")] { - crate::wallet::storage::adapter::rocksdb::RocksdbStorageAdapter::new(storage_options.path.clone())? + let storage = crate::wallet::storage::adapter::rocksdb::RocksdbStorageAdapter::new(storage_options.path.clone())?; } else if #[cfg(feature = "jammdb")] { - crate::wallet::storage::adapter::jammdb::JammdbStorageAdapter::new(storage_options.path.clone())? + let storage = crate::wallet::storage::adapter::jammdb::JammdbStorageAdapter::new(storage_options.path.clone())?; } else { - crate::wallet::storage::adapter::memory::Memory::default() + let storage = crate::wallet::storage::adapter::memory::Memory::default(); } - ); + ) #[cfg(feature = "storage")] let mut storage_manager = StorageManager::new(storage, storage_options.encryption_key.clone()).await?; From d63b9a2e9af8dc94bdc10ba19d356e54bf3203cf Mon Sep 17 00:00:00 2001 From: Alexandcoats Date: Mon, 28 Aug 2023 09:03:12 -0400 Subject: [PATCH 42/48] Update sdk/src/wallet/storage/kind.rs --- sdk/src/wallet/storage/kind.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/src/wallet/storage/kind.rs b/sdk/src/wallet/storage/kind.rs index c2384c388f..7c883b0b68 100644 --- a/sdk/src/wallet/storage/kind.rs +++ b/sdk/src/wallet/storage/kind.rs @@ -32,6 +32,6 @@ impl Default for StorageKind { } else { Self::Memory } - ); + ) } } From aa3cf39ed89a14a6fcb897c8ae0715fe5bae467f Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Mon, 28 Aug 2023 17:56:40 +0200 Subject: [PATCH 43/48] added missing semi-colon --- sdk/src/wallet/core/builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/src/wallet/core/builder.rs b/sdk/src/wallet/core/builder.rs index 53b2cebc0d..b7e06edd93 100644 --- a/sdk/src/wallet/core/builder.rs +++ b/sdk/src/wallet/core/builder.rs @@ -141,7 +141,7 @@ where } else { let storage = crate::wallet::storage::adapter::memory::Memory::default(); } - ) + ); #[cfg(feature = "storage")] let mut storage_manager = StorageManager::new(storage, storage_options.encryption_key.clone()).await?; From 1e595cc5def336f2764c906c6d3915f17904ed03 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Tue, 29 Aug 2023 08:32:19 +0200 Subject: [PATCH 44/48] fixed cfg_if parentheses --- sdk/src/wallet/core/builder.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sdk/src/wallet/core/builder.rs b/sdk/src/wallet/core/builder.rs index b7e06edd93..58cd4e1002 100644 --- a/sdk/src/wallet/core/builder.rs +++ b/sdk/src/wallet/core/builder.rs @@ -133,15 +133,15 @@ where } #[cfg(feature = "storage")] - cfg_if::cfg_if!( - if #[cfg(feature = "rocksdb")] { - let storage = crate::wallet::storage::adapter::rocksdb::RocksdbStorageAdapter::new(storage_options.path.clone())?; - } else if #[cfg(feature = "jammdb")] { - let storage = crate::wallet::storage::adapter::jammdb::JammdbStorageAdapter::new(storage_options.path.clone())?; - } else { - let storage = crate::wallet::storage::adapter::memory::Memory::default(); - } - ); + cfg_if::cfg_if! { + if #[cfg(feature = "rocksdb")] { + let storage = crate::wallet::storage::adapter::rocksdb::RocksdbStorageAdapter::new(storage_options.path.clone())?; + } else if #[cfg(feature = "jammdb")] { + let storage = crate::wallet::storage::adapter::jammdb::JammdbStorageAdapter::new(storage_options.path.clone())?; + } else { + let storage = crate::wallet::storage::adapter::memory::Memory::default(); + } + } #[cfg(feature = "storage")] let mut storage_manager = StorageManager::new(storage, storage_options.encryption_key.clone()).await?; From 44e754eebf6974308c163a1b10c898bfaae911d8 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Tue, 29 Aug 2023 08:32:27 +0200 Subject: [PATCH 45/48] fixed cfg_if parentheses --- sdk/src/wallet/storage/kind.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/src/wallet/storage/kind.rs b/sdk/src/wallet/storage/kind.rs index 7c883b0b68..757d4ab03c 100644 --- a/sdk/src/wallet/storage/kind.rs +++ b/sdk/src/wallet/storage/kind.rs @@ -22,16 +22,16 @@ pub enum StorageKind { impl Default for StorageKind { fn default() -> Self { - cfg_if::cfg_if!( + cfg_if::cfg_if! { if #[cfg(feature = "rocksdb")] { Self::Rocksdb } else if #[cfg(feature = "jammdb")] { - Self::Jammdb + Self::Jammdb; } else if #[cfg(target_family = "wasm")] { - Self::Wasm + Self::Wasm; } else { Self::Memory } - ) + } } } From 80e56b00fc28264cd3c86ea5fccf870ff9fc99ac Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Tue, 29 Aug 2023 08:32:45 +0200 Subject: [PATCH 46/48] updated lock file --- Cargo.lock | 1 - 1 file changed, 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index fdab9d29e0..1c2747517d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1594,7 +1594,6 @@ dependencies = [ "bitflags 2.3.3", "bytemuck", "cfg-if", - "derive_builder", "derive_more", "dotenvy", "fern-logger", From 0cdb68c055c8a4df0089a61647156d2f71f1f1a4 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Tue, 29 Aug 2023 08:34:57 +0200 Subject: [PATCH 47/48] cargo fmt --- sdk/src/wallet/core/builder.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sdk/src/wallet/core/builder.rs b/sdk/src/wallet/core/builder.rs index 58cd4e1002..9ba04d3993 100644 --- a/sdk/src/wallet/core/builder.rs +++ b/sdk/src/wallet/core/builder.rs @@ -134,13 +134,13 @@ where #[cfg(feature = "storage")] cfg_if::cfg_if! { - if #[cfg(feature = "rocksdb")] { - let storage = crate::wallet::storage::adapter::rocksdb::RocksdbStorageAdapter::new(storage_options.path.clone())?; - } else if #[cfg(feature = "jammdb")] { - let storage = crate::wallet::storage::adapter::jammdb::JammdbStorageAdapter::new(storage_options.path.clone())?; - } else { - let storage = crate::wallet::storage::adapter::memory::Memory::default(); - } + if #[cfg(feature = "rocksdb")] { + let storage = crate::wallet::storage::adapter::rocksdb::RocksdbStorageAdapter::new(storage_options.path.clone())?; + } else if #[cfg(feature = "jammdb")] { + let storage = crate::wallet::storage::adapter::jammdb::JammdbStorageAdapter::new(storage_options.path.clone())?; + } else { + let storage = crate::wallet::storage::adapter::memory::Memory::default(); + } } #[cfg(feature = "storage")] From 7e35a5fc37f3df45a4822d6e16f9acaa009ab143 Mon Sep 17 00:00:00 2001 From: sparnerkar Date: Thu, 31 Aug 2023 10:14:48 +0200 Subject: [PATCH 48/48] removed semi-colons added by auto-fmt --- sdk/src/wallet/storage/kind.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/src/wallet/storage/kind.rs b/sdk/src/wallet/storage/kind.rs index 757d4ab03c..59508d577c 100644 --- a/sdk/src/wallet/storage/kind.rs +++ b/sdk/src/wallet/storage/kind.rs @@ -26,9 +26,9 @@ impl Default for StorageKind { if #[cfg(feature = "rocksdb")] { Self::Rocksdb } else if #[cfg(feature = "jammdb")] { - Self::Jammdb; + Self::Jammdb } else if #[cfg(target_family = "wasm")] { - Self::Wasm; + Self::Wasm } else { Self::Memory }