diff --git a/wallet/src/account/mod.rs b/wallet/src/account/mod.rs index 8795a8fed..410e8f155 100644 --- a/wallet/src/account/mod.rs +++ b/wallet/src/account/mod.rs @@ -75,8 +75,8 @@ use std::collections::{BTreeMap, BTreeSet}; use std::ops::{Add, Sub}; use std::sync::Arc; use wallet_storage::{ - StoreTxRw, WalletStorageReadLocked, WalletStorageReadUnlocked, WalletStorageReadWriteLocked, - WalletStorageWriteLocked, WalletStorageWriteUnlocked, + StoreTxRw, WalletStorageReadLocked, WalletStorageReadUnlocked, WalletStorageWriteLocked, + WalletStorageWriteUnlocked, }; use wallet_types::utxo_types::{get_utxo_type, UtxoState, UtxoStates, UtxoType, UtxoTypes}; use wallet_types::wallet_tx::{BlockData, TxData, TxState}; @@ -1955,7 +1955,7 @@ impl Account { pub fn scan_new_inmempool_transactions( &mut self, transactions: &[SignedTransaction], - db_tx: &mut impl WalletStorageReadWriteLocked, + db_tx: &mut impl WalletStorageWriteLocked, wallet_events: &impl WalletEvents, ) -> WalletResult<()> { self.scan_new_unconfirmed_transactions( @@ -1969,7 +1969,7 @@ impl Account { pub fn scan_new_inactive_transactions( &mut self, transactions: &[SignedTransaction], - db_tx: &mut impl WalletStorageReadWriteLocked, + db_tx: &mut impl WalletStorageWriteLocked, wallet_events: &impl WalletEvents, ) -> WalletResult<()> { self.scan_new_unconfirmed_transactions( @@ -1984,7 +1984,7 @@ impl Account { &mut self, transactions: &[SignedTransaction], make_tx_state: fn(u64) -> TxState, - db_tx: &mut impl WalletStorageReadWriteLocked, + db_tx: &mut impl WalletStorageWriteLocked, wallet_events: &impl WalletEvents, ) -> WalletResult<()> { let account_id = self.get_account_id(); diff --git a/wallet/src/key_chain/master_key_chain/mod.rs b/wallet/src/key_chain/master_key_chain/mod.rs index 4f4905eb0..a93eb60b9 100644 --- a/wallet/src/key_chain/master_key_chain/mod.rs +++ b/wallet/src/key_chain/master_key_chain/mod.rs @@ -22,7 +22,7 @@ use crypto::vrf::ExtendedVRFPrivateKey; use std::sync::Arc; use wallet_storage::{ StoreTxRwUnlocked, WalletStorageReadLocked, WalletStorageReadUnlocked, - WalletStorageReadWriteUnlocked, WalletStorageWriteUnlocked, + WalletStorageWriteUnlocked, }; use wallet_types::seed_phrase::{SerializableSeedPhrase, StoreSeedPhrase}; @@ -131,7 +131,7 @@ impl MasterKeyChain { pub fn create_account_key_chain( &self, - db_tx: &mut impl WalletStorageReadWriteUnlocked, + db_tx: &mut impl WalletStorageWriteUnlocked, account_index: U31, lookahead_size: u32, ) -> KeyChainResult { diff --git a/wallet/src/signer/mod.rs b/wallet/src/signer/mod.rs index 79c7d83c7..eecfb8b3e 100644 --- a/wallet/src/signer/mod.rs +++ b/wallet/src/signer/mod.rs @@ -35,7 +35,7 @@ use crypto::key::{ SignatureError, }; use wallet_storage::{ - WalletStorageReadLocked, WalletStorageReadUnlocked, WalletStorageReadWriteUnlocked, + WalletStorageReadLocked, WalletStorageReadUnlocked, WalletStorageWriteUnlocked, }; use wallet_types::{ partially_signed_transaction::PartiallySignedTransaction, signature_status::SignatureStatus, @@ -147,7 +147,7 @@ pub trait SignerProvider { chain_config: Arc, account_index: U31, name: Option, - db_tx: &mut impl WalletStorageReadWriteUnlocked, + db_tx: &mut impl WalletStorageWriteUnlocked, ) -> WalletResult>; fn load_account_from_database( diff --git a/wallet/src/signer/software_signer/mod.rs b/wallet/src/signer/software_signer/mod.rs index 668841e13..07dc1a7a9 100644 --- a/wallet/src/signer/software_signer/mod.rs +++ b/wallet/src/signer/software_signer/mod.rs @@ -46,7 +46,7 @@ use itertools::Itertools; use randomness::make_true_rng; use wallet_storage::{ StoreTxRwUnlocked, WalletStorageReadLocked, WalletStorageReadUnlocked, - WalletStorageReadWriteUnlocked, + WalletStorageWriteUnlocked, }; use wallet_types::{ partially_signed_transaction::PartiallySignedTransaction, seed_phrase::StoreSeedPhrase, @@ -463,7 +463,7 @@ impl SignerProvider for SoftwareSignerProvider { chain_config: Arc, next_account_index: U31, name: Option, - db_tx: &mut impl WalletStorageReadWriteUnlocked, + db_tx: &mut impl WalletStorageWriteUnlocked, ) -> WalletResult> { let lookahead_size = db_tx.get_lookahead_size()?; let account_key_chain = self.master_key_chain.create_account_key_chain( diff --git a/wallet/src/signer/trezor_signer/mod.rs b/wallet/src/signer/trezor_signer/mod.rs index 21fc0ab0c..f916c1c1e 100644 --- a/wallet/src/signer/trezor_signer/mod.rs +++ b/wallet/src/signer/trezor_signer/mod.rs @@ -78,7 +78,7 @@ use trezor_client::{ }; use utils::ensure; use wallet_storage::{ - WalletStorageReadLocked, WalletStorageReadUnlocked, WalletStorageReadWriteUnlocked, + WalletStorageReadLocked, WalletStorageReadUnlocked, WalletStorageWriteUnlocked, }; use wallet_types::{ account_info::DEFAULT_ACCOUNT_INDEX, @@ -1151,7 +1151,7 @@ impl SignerProvider for TrezorSignerProvider { chain_config: Arc, account_index: U31, name: Option, - db_tx: &mut impl WalletStorageReadWriteUnlocked, + db_tx: &mut impl WalletStorageWriteUnlocked, ) -> WalletResult> { let account_pubkey = self.fetch_extended_pub_key(&chain_config, account_index)?; diff --git a/wallet/src/wallet/mod.rs b/wallet/src/wallet/mod.rs index 0ba73728d..560f25acd 100644 --- a/wallet/src/wallet/mod.rs +++ b/wallet/src/wallet/mod.rs @@ -71,8 +71,8 @@ pub use wallet_storage::Error; use wallet_storage::{ DefaultBackend, Store, StoreLocalReadWriteUnlocked, StoreTxRo, StoreTxRw, StoreTxRwUnlocked, TransactionRoLocked, TransactionRwLocked, TransactionRwUnlocked, Transactional, - WalletStorageReadLocked, WalletStorageReadUnlocked, WalletStorageReadWriteLocked, - WalletStorageReadWriteUnlocked, WalletStorageWriteLocked, WalletStorageWriteUnlocked, + WalletStorageReadLocked, WalletStorageReadUnlocked, WalletStorageWriteLocked, + WalletStorageWriteUnlocked, }; use wallet_types::account_info::{StandaloneAddressDetails, StandaloneAddresses}; use wallet_types::chain_info::ChainInfo; @@ -672,7 +672,7 @@ where fn reset_wallet_transactions( chain_config: Arc, - db_tx: &mut impl WalletStorageReadWriteLocked, + db_tx: &mut impl WalletStorageWriteLocked, ) -> WalletResult<()> { db_tx.clear_transactions()?; db_tx.clear_addresses()?; @@ -703,7 +703,7 @@ where fn reset_wallet_transactions_and_load( chain_config: Arc, - db_tx: &mut impl WalletStorageReadWriteLocked, + db_tx: &mut impl WalletStorageWriteLocked, signer_provider: &P, ) -> WalletResult>> { Self::reset_wallet_transactions(chain_config.clone(), db_tx)?; @@ -725,7 +725,7 @@ where fn migrate_next_unused_account( chain_config: Arc, - db_tx: &mut impl WalletStorageReadWriteUnlocked, + db_tx: &mut impl WalletStorageWriteUnlocked, signer_provider: &mut P, ) -> Result<(), WalletError> { let accounts_info = db_tx.get_accounts_info()?; @@ -903,7 +903,7 @@ where fn create_next_unused_account( next_account_index: U31, chain_config: Arc, - db_tx: &mut impl WalletStorageReadWriteUnlocked, + db_tx: &mut impl WalletStorageWriteUnlocked, name: Option, signer_provider: &mut P, ) -> WalletResult<(U31, Account)> { diff --git a/wallet/storage/src/internal/store_tx.rs b/wallet/storage/src/internal/store_tx.rs index da61f4e15..bf8dacf20 100644 --- a/wallet/storage/src/internal/store_tx.rs +++ b/wallet/storage/src/internal/store_tx.rs @@ -1293,8 +1293,6 @@ impl<'st, B: storage::Backend> crate::TransactionRoUnlocked for StoreTxRoUnlocke } } -impl<'st, B: storage::Backend> crate::WalletStorageReadWriteLocked for StoreTxRw<'st, B> {} - impl<'st, B: storage::Backend> crate::TransactionRwLocked for StoreTxRw<'st, B> { fn commit(self) -> crate::Result<()> { self.storage.commit().map_err(Into::into) @@ -1305,9 +1303,6 @@ impl<'st, B: storage::Backend> crate::TransactionRwLocked for StoreTxRw<'st, B> } } -impl<'st, B: storage::Backend> crate::WalletStorageReadWriteLocked for StoreTxRwUnlocked<'st, B> {} -impl<'st, B: storage::Backend> crate::WalletStorageReadWriteUnlocked for StoreTxRwUnlocked<'st, B> {} - impl<'st, B: storage::Backend> crate::TransactionRwUnlocked for StoreTxRwUnlocked<'st, B> { fn commit(self) -> crate::Result<()> { self.storage.commit().map_err(Into::into) diff --git a/wallet/storage/src/lib.rs b/wallet/storage/src/lib.rs index caf1b1434..e38a8919f 100644 --- a/wallet/storage/src/lib.rs +++ b/wallet/storage/src/lib.rs @@ -139,7 +139,7 @@ pub trait WalletStorageEncryptionRead { } /// Modifying operations on persistent wallet data -pub trait WalletStorageWriteLocked { +pub trait WalletStorageWriteLocked: WalletStorageReadLocked { /// Set storage version fn set_storage_version(&mut self, version: u32) -> Result<()>; fn set_wallet_type(&mut self, wallet_type: WalletType) -> Result<()>; @@ -202,7 +202,7 @@ pub trait WalletStorageWriteLocked { } /// Modifying operations on persistent wallet data with access to encrypted data -pub trait WalletStorageWriteUnlocked: WalletStorageWriteLocked { +pub trait WalletStorageWriteUnlocked: WalletStorageWriteLocked + WalletStorageReadUnlocked { fn set_root_key(&mut self, content: &RootKeys) -> Result<()>; fn del_root_key(&mut self) -> Result<()>; fn set_seed_phrase(&mut self, seed_phrase: SerializableSeedPhrase) -> Result<()>; @@ -223,13 +223,6 @@ pub trait WalletStorageEncryptionWrite { fn encrypt_seed_phrase(&mut self, new_encryption_key: &Option) -> Result<()>; } -pub trait WalletStorageReadWriteLocked: WalletStorageReadLocked + WalletStorageWriteLocked {} - -pub trait WalletStorageReadWriteUnlocked: - WalletStorageReadUnlocked + WalletStorageWriteUnlocked + WalletStorageReadWriteLocked -{ -} - /// Marker trait for types where read/write operations are run in a transaction pub trait IsTransaction: is_transaction_seal::Seal {} @@ -246,7 +239,7 @@ pub trait TransactionRoUnlocked: WalletStorageReadUnlocked + IsTransaction { } /// Operations on read-write transactions -pub trait TransactionRwLocked: WalletStorageReadWriteLocked + IsTransaction { +pub trait TransactionRwLocked: WalletStorageWriteLocked + IsTransaction { /// Abort the transaction fn abort(self); @@ -255,7 +248,7 @@ pub trait TransactionRwLocked: WalletStorageReadWriteLocked + IsTransaction { } /// Operations on read-write transactions -pub trait TransactionRwUnlocked: WalletStorageReadWriteUnlocked + IsTransaction { +pub trait TransactionRwUnlocked: WalletStorageWriteUnlocked + IsTransaction { /// Abort the transaction fn abort(self); @@ -293,10 +286,7 @@ pub trait Transactional<'t> { ) -> Result; } -pub trait WalletStorage: - WalletStorageWriteLocked + WalletStorageReadLocked + for<'tx> Transactional<'tx> + Send -{ -} +pub trait WalletStorage: WalletStorageWriteLocked + for<'tx> Transactional<'tx> + Send {} pub type DefaultBackend = storage_sqlite::Sqlite; pub type WalletStorageTxRwImpl<'st> = StoreTxRw<'st, storage_sqlite::Sqlite>;