Skip to content

Commit f0dcbbc

Browse files
committed
Remove extra storage traits
1 parent fd89e56 commit f0dcbbc

File tree

8 files changed

+24
-39
lines changed

8 files changed

+24
-39
lines changed

wallet/src/account/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ use std::collections::{BTreeMap, BTreeSet};
7575
use std::ops::{Add, Sub};
7676
use std::sync::Arc;
7777
use wallet_storage::{
78-
StoreTxRw, WalletStorageReadLocked, WalletStorageReadUnlocked, WalletStorageReadWriteLocked,
79-
WalletStorageWriteLocked, WalletStorageWriteUnlocked,
78+
StoreTxRw, WalletStorageReadLocked, WalletStorageReadUnlocked, WalletStorageWriteLocked,
79+
WalletStorageWriteUnlocked,
8080
};
8181
use wallet_types::utxo_types::{get_utxo_type, UtxoState, UtxoStates, UtxoType, UtxoTypes};
8282
use wallet_types::wallet_tx::{BlockData, TxData, TxState};
@@ -1955,7 +1955,7 @@ impl<K: AccountKeyChains + Sync> Account<K> {
19551955
pub fn scan_new_inmempool_transactions(
19561956
&mut self,
19571957
transactions: &[SignedTransaction],
1958-
db_tx: &mut impl WalletStorageReadWriteLocked,
1958+
db_tx: &mut impl WalletStorageWriteLocked,
19591959
wallet_events: &impl WalletEvents,
19601960
) -> WalletResult<()> {
19611961
self.scan_new_unconfirmed_transactions(
@@ -1969,7 +1969,7 @@ impl<K: AccountKeyChains + Sync> Account<K> {
19691969
pub fn scan_new_inactive_transactions(
19701970
&mut self,
19711971
transactions: &[SignedTransaction],
1972-
db_tx: &mut impl WalletStorageReadWriteLocked,
1972+
db_tx: &mut impl WalletStorageWriteLocked,
19731973
wallet_events: &impl WalletEvents,
19741974
) -> WalletResult<()> {
19751975
self.scan_new_unconfirmed_transactions(
@@ -1984,7 +1984,7 @@ impl<K: AccountKeyChains + Sync> Account<K> {
19841984
&mut self,
19851985
transactions: &[SignedTransaction],
19861986
make_tx_state: fn(u64) -> TxState,
1987-
db_tx: &mut impl WalletStorageReadWriteLocked,
1987+
db_tx: &mut impl WalletStorageWriteLocked,
19881988
wallet_events: &impl WalletEvents,
19891989
) -> WalletResult<()> {
19901990
let account_id = self.get_account_id();

wallet/src/key_chain/master_key_chain/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crypto::vrf::ExtendedVRFPrivateKey;
2222
use std::sync::Arc;
2323
use wallet_storage::{
2424
StoreTxRwUnlocked, WalletStorageReadLocked, WalletStorageReadUnlocked,
25-
WalletStorageReadWriteUnlocked, WalletStorageWriteUnlocked,
25+
WalletStorageWriteUnlocked,
2626
};
2727
use wallet_types::seed_phrase::{SerializableSeedPhrase, StoreSeedPhrase};
2828

@@ -131,7 +131,7 @@ impl MasterKeyChain {
131131

132132
pub fn create_account_key_chain(
133133
&self,
134-
db_tx: &mut impl WalletStorageReadWriteUnlocked,
134+
db_tx: &mut impl WalletStorageWriteUnlocked,
135135
account_index: U31,
136136
lookahead_size: u32,
137137
) -> KeyChainResult<AccountKeyChainImplSoftware> {

wallet/src/signer/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use crypto::key::{
3535
SignatureError,
3636
};
3737
use wallet_storage::{
38-
WalletStorageReadLocked, WalletStorageReadUnlocked, WalletStorageReadWriteUnlocked,
38+
WalletStorageReadLocked, WalletStorageReadUnlocked, WalletStorageWriteUnlocked,
3939
};
4040
use wallet_types::{
4141
partially_signed_transaction::PartiallySignedTransaction, signature_status::SignatureStatus,
@@ -147,7 +147,7 @@ pub trait SignerProvider {
147147
chain_config: Arc<ChainConfig>,
148148
account_index: U31,
149149
name: Option<String>,
150-
db_tx: &mut impl WalletStorageReadWriteUnlocked,
150+
db_tx: &mut impl WalletStorageWriteUnlocked,
151151
) -> WalletResult<Account<Self::K>>;
152152

153153
fn load_account_from_database(

wallet/src/signer/software_signer/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use itertools::Itertools;
4646
use randomness::make_true_rng;
4747
use wallet_storage::{
4848
StoreTxRwUnlocked, WalletStorageReadLocked, WalletStorageReadUnlocked,
49-
WalletStorageReadWriteUnlocked,
49+
WalletStorageWriteUnlocked,
5050
};
5151
use wallet_types::{
5252
partially_signed_transaction::PartiallySignedTransaction, seed_phrase::StoreSeedPhrase,
@@ -463,7 +463,7 @@ impl SignerProvider for SoftwareSignerProvider {
463463
chain_config: Arc<ChainConfig>,
464464
next_account_index: U31,
465465
name: Option<String>,
466-
db_tx: &mut impl WalletStorageReadWriteUnlocked,
466+
db_tx: &mut impl WalletStorageWriteUnlocked,
467467
) -> WalletResult<Account<AccountKeyChainImplSoftware>> {
468468
let lookahead_size = db_tx.get_lookahead_size()?;
469469
let account_key_chain = self.master_key_chain.create_account_key_chain(

wallet/src/signer/trezor_signer/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ use trezor_client::{
7878
};
7979
use utils::ensure;
8080
use wallet_storage::{
81-
WalletStorageReadLocked, WalletStorageReadUnlocked, WalletStorageReadWriteUnlocked,
81+
WalletStorageReadLocked, WalletStorageReadUnlocked, WalletStorageWriteUnlocked,
8282
};
8383
use wallet_types::{
8484
account_info::DEFAULT_ACCOUNT_INDEX,
@@ -1151,7 +1151,7 @@ impl SignerProvider for TrezorSignerProvider {
11511151
chain_config: Arc<ChainConfig>,
11521152
account_index: U31,
11531153
name: Option<String>,
1154-
db_tx: &mut impl WalletStorageReadWriteUnlocked,
1154+
db_tx: &mut impl WalletStorageWriteUnlocked,
11551155
) -> WalletResult<Account<Self::K>> {
11561156
let account_pubkey = self.fetch_extended_pub_key(&chain_config, account_index)?;
11571157

wallet/src/wallet/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ pub use wallet_storage::Error;
7171
use wallet_storage::{
7272
DefaultBackend, Store, StoreLocalReadWriteUnlocked, StoreTxRo, StoreTxRw, StoreTxRwUnlocked,
7373
TransactionRoLocked, TransactionRwLocked, TransactionRwUnlocked, Transactional,
74-
WalletStorageReadLocked, WalletStorageReadUnlocked, WalletStorageReadWriteLocked,
75-
WalletStorageReadWriteUnlocked, WalletStorageWriteLocked, WalletStorageWriteUnlocked,
74+
WalletStorageReadLocked, WalletStorageReadUnlocked, WalletStorageWriteLocked,
75+
WalletStorageWriteUnlocked,
7676
};
7777
use wallet_types::account_info::{StandaloneAddressDetails, StandaloneAddresses};
7878
use wallet_types::chain_info::ChainInfo;
@@ -672,7 +672,7 @@ where
672672

673673
fn reset_wallet_transactions(
674674
chain_config: Arc<ChainConfig>,
675-
db_tx: &mut impl WalletStorageReadWriteLocked,
675+
db_tx: &mut impl WalletStorageWriteLocked,
676676
) -> WalletResult<()> {
677677
db_tx.clear_transactions()?;
678678
db_tx.clear_addresses()?;
@@ -703,7 +703,7 @@ where
703703

704704
fn reset_wallet_transactions_and_load(
705705
chain_config: Arc<ChainConfig>,
706-
db_tx: &mut impl WalletStorageReadWriteLocked,
706+
db_tx: &mut impl WalletStorageWriteLocked,
707707
signer_provider: &P,
708708
) -> WalletResult<BTreeMap<U31, Account<P::K>>> {
709709
Self::reset_wallet_transactions(chain_config.clone(), db_tx)?;
@@ -725,7 +725,7 @@ where
725725

726726
fn migrate_next_unused_account(
727727
chain_config: Arc<ChainConfig>,
728-
db_tx: &mut impl WalletStorageReadWriteUnlocked,
728+
db_tx: &mut impl WalletStorageWriteUnlocked,
729729
signer_provider: &mut P,
730730
) -> Result<(), WalletError> {
731731
let accounts_info = db_tx.get_accounts_info()?;
@@ -903,7 +903,7 @@ where
903903
fn create_next_unused_account(
904904
next_account_index: U31,
905905
chain_config: Arc<ChainConfig>,
906-
db_tx: &mut impl WalletStorageReadWriteUnlocked,
906+
db_tx: &mut impl WalletStorageWriteUnlocked,
907907
name: Option<String>,
908908
signer_provider: &mut P,
909909
) -> WalletResult<(U31, Account<P::K>)> {

wallet/storage/src/internal/store_tx.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,8 +1293,6 @@ impl<'st, B: storage::Backend> crate::TransactionRoUnlocked for StoreTxRoUnlocke
12931293
}
12941294
}
12951295

1296-
impl<'st, B: storage::Backend> crate::WalletStorageReadWriteLocked for StoreTxRw<'st, B> {}
1297-
12981296
impl<'st, B: storage::Backend> crate::TransactionRwLocked for StoreTxRw<'st, B> {
12991297
fn commit(self) -> crate::Result<()> {
13001298
self.storage.commit().map_err(Into::into)
@@ -1305,9 +1303,6 @@ impl<'st, B: storage::Backend> crate::TransactionRwLocked for StoreTxRw<'st, B>
13051303
}
13061304
}
13071305

1308-
impl<'st, B: storage::Backend> crate::WalletStorageReadWriteLocked for StoreTxRwUnlocked<'st, B> {}
1309-
impl<'st, B: storage::Backend> crate::WalletStorageReadWriteUnlocked for StoreTxRwUnlocked<'st, B> {}
1310-
13111306
impl<'st, B: storage::Backend> crate::TransactionRwUnlocked for StoreTxRwUnlocked<'st, B> {
13121307
fn commit(self) -> crate::Result<()> {
13131308
self.storage.commit().map_err(Into::into)

wallet/storage/src/lib.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ pub trait WalletStorageEncryptionRead {
139139
}
140140

141141
/// Modifying operations on persistent wallet data
142-
pub trait WalletStorageWriteLocked {
142+
pub trait WalletStorageWriteLocked: WalletStorageReadLocked {
143143
/// Set storage version
144144
fn set_storage_version(&mut self, version: u32) -> Result<()>;
145145
fn set_wallet_type(&mut self, wallet_type: WalletType) -> Result<()>;
@@ -202,7 +202,7 @@ pub trait WalletStorageWriteLocked {
202202
}
203203

204204
/// Modifying operations on persistent wallet data with access to encrypted data
205-
pub trait WalletStorageWriteUnlocked: WalletStorageWriteLocked {
205+
pub trait WalletStorageWriteUnlocked: WalletStorageWriteLocked + WalletStorageReadUnlocked {
206206
fn set_root_key(&mut self, content: &RootKeys) -> Result<()>;
207207
fn del_root_key(&mut self) -> Result<()>;
208208
fn set_seed_phrase(&mut self, seed_phrase: SerializableSeedPhrase) -> Result<()>;
@@ -223,13 +223,6 @@ pub trait WalletStorageEncryptionWrite {
223223
fn encrypt_seed_phrase(&mut self, new_encryption_key: &Option<SymmetricKey>) -> Result<()>;
224224
}
225225

226-
pub trait WalletStorageReadWriteLocked: WalletStorageReadLocked + WalletStorageWriteLocked {}
227-
228-
pub trait WalletStorageReadWriteUnlocked:
229-
WalletStorageReadUnlocked + WalletStorageWriteUnlocked + WalletStorageReadWriteLocked
230-
{
231-
}
232-
233226
/// Marker trait for types where read/write operations are run in a transaction
234227
pub trait IsTransaction: is_transaction_seal::Seal {}
235228

@@ -246,7 +239,7 @@ pub trait TransactionRoUnlocked: WalletStorageReadUnlocked + IsTransaction {
246239
}
247240

248241
/// Operations on read-write transactions
249-
pub trait TransactionRwLocked: WalletStorageReadWriteLocked + IsTransaction {
242+
pub trait TransactionRwLocked: WalletStorageWriteLocked + IsTransaction {
250243
/// Abort the transaction
251244
fn abort(self);
252245

@@ -255,7 +248,7 @@ pub trait TransactionRwLocked: WalletStorageReadWriteLocked + IsTransaction {
255248
}
256249

257250
/// Operations on read-write transactions
258-
pub trait TransactionRwUnlocked: WalletStorageReadWriteUnlocked + IsTransaction {
251+
pub trait TransactionRwUnlocked: WalletStorageWriteUnlocked + IsTransaction {
259252
/// Abort the transaction
260253
fn abort(self);
261254

@@ -293,10 +286,7 @@ pub trait Transactional<'t> {
293286
) -> Result<Self::TransactionRwUnlocked>;
294287
}
295288

296-
pub trait WalletStorage:
297-
WalletStorageWriteLocked + WalletStorageReadLocked + for<'tx> Transactional<'tx> + Send
298-
{
299-
}
289+
pub trait WalletStorage: WalletStorageWriteLocked + for<'tx> Transactional<'tx> + Send {}
300290

301291
pub type DefaultBackend = storage_sqlite::Sqlite;
302292
pub type WalletStorageTxRwImpl<'st> = StoreTxRw<'st, storage_sqlite::Sqlite>;

0 commit comments

Comments
 (0)