Skip to content

Commit 142784d

Browse files
committed
Have Wallet take PaymentStore ref
1 parent 7090530 commit 142784d

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

src/builder.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -855,11 +855,22 @@ fn build_with_store_internal(
855855

856856
let tx_broadcaster = Arc::new(TransactionBroadcaster::new(Arc::clone(&logger)));
857857
let fee_estimator = Arc::new(OnchainFeeEstimator::new());
858+
859+
let payment_store = match io::utils::read_payments(Arc::clone(&kv_store), Arc::clone(&logger)) {
860+
Ok(payments) => {
861+
Arc::new(PaymentStore::new(payments, Arc::clone(&kv_store), Arc::clone(&logger)))
862+
},
863+
Err(_) => {
864+
return Err(BuildError::ReadFailed);
865+
},
866+
};
867+
858868
let wallet = Arc::new(Wallet::new(
859869
bdk_wallet,
860870
wallet_persister,
861871
Arc::clone(&tx_broadcaster),
862872
Arc::clone(&fee_estimator),
873+
Arc::clone(&payment_store),
863874
Arc::clone(&logger),
864875
));
865876

@@ -1249,16 +1260,6 @@ fn build_with_store_internal(
12491260
},
12501261
}
12511262

1252-
// Init payment info storage
1253-
let payment_store = match io::utils::read_payments(Arc::clone(&kv_store), Arc::clone(&logger)) {
1254-
Ok(payments) => {
1255-
Arc::new(PaymentStore::new(payments, Arc::clone(&kv_store), Arc::clone(&logger)))
1256-
},
1257-
Err(_) => {
1258-
return Err(BuildError::ReadFailed);
1259-
},
1260-
};
1261-
12621263
let event_queue = match io::utils::read_event_queue(Arc::clone(&kv_store), Arc::clone(&logger))
12631264
{
12641265
Ok(event_queue) => Arc::new(event_queue),

src/wallet/mod.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77

88
use persist::KVStoreWalletPersister;
99

10-
use crate::logger::{log_debug, log_error, log_info, log_trace, LdkLogger};
10+
use crate::logger::{log_debug, log_error, log_info, log_trace, Logger, LdkLogger};
1111

1212
use crate::fee_estimator::{ConfirmationTarget, FeeEstimator};
13+
use crate::payment::store::PaymentStore;
1314
use crate::Error;
1415

1516
use lightning::chain::chaininterface::BroadcasterInterface;
@@ -66,6 +67,7 @@ where
6667
persister: Mutex<KVStoreWalletPersister>,
6768
broadcaster: B,
6869
fee_estimator: E,
70+
payment_store: Arc<PaymentStore<Arc<Logger>>>,
6971
logger: L,
7072
}
7173

@@ -77,11 +79,12 @@ where
7779
{
7880
pub(crate) fn new(
7981
wallet: bdk_wallet::PersistedWallet<KVStoreWalletPersister>,
80-
wallet_persister: KVStoreWalletPersister, broadcaster: B, fee_estimator: E, logger: L,
82+
wallet_persister: KVStoreWalletPersister, broadcaster: B, fee_estimator: E,
83+
payment_store: Arc<PaymentStore<Arc<Logger>>>, logger: L,
8184
) -> Self {
8285
let inner = Mutex::new(wallet);
8386
let persister = Mutex::new(wallet_persister);
84-
Self { inner, persister, broadcaster, fee_estimator, logger }
87+
Self { inner, persister, broadcaster, fee_estimator, payment_store, logger }
8588
}
8689

8790
pub(crate) fn get_full_scan_request(&self) -> FullScanRequest<KeychainKind> {

0 commit comments

Comments
 (0)