Skip to content

Commit f5d699d

Browse files
committed
Rename persister in handle_ldk_events to differentiate store
Since we now have a `Persist`er which is separate from our `FilesystemStore`, its useful to use different names to differentiate the two.
1 parent f27446d commit f5d699d

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/cli.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub(crate) fn poll_for_user_input(
6565
keys_manager: Arc<KeysManager>, network_graph: Arc<NetworkGraph>,
6666
onion_messenger: Arc<OnionMessenger>, inbound_payments: Arc<Mutex<PaymentInfoStorage>>,
6767
outbound_payments: Arc<Mutex<PaymentInfoStorage>>, ldk_data_dir: String, network: Network,
68-
logger: Arc<disk::FilesystemLogger>, persister: Arc<FilesystemStore>,
68+
logger: Arc<disk::FilesystemLogger>, fs_store: Arc<FilesystemStore>,
6969
) {
7070
println!(
7171
"LDK startup successful. Enter \"help\" to view available commands. Press Ctrl-D to quit."
@@ -172,7 +172,7 @@ pub(crate) fn poll_for_user_input(
172172
&channel_manager,
173173
&invoice,
174174
&mut outbound_payments.lock().unwrap(),
175-
persister.clone(),
175+
Arc::clone(&fs_store),
176176
);
177177
}
178178
"keysend" => {
@@ -209,7 +209,7 @@ pub(crate) fn poll_for_user_input(
209209
amt_msat,
210210
&*keys_manager,
211211
&mut outbound_payments.lock().unwrap(),
212-
persister.clone(),
212+
Arc::clone(&fs_store),
213213
);
214214
}
215215
"getinvoice" => {
@@ -247,7 +247,7 @@ pub(crate) fn poll_for_user_input(
247247
expiry_secs.unwrap(),
248248
Arc::clone(&logger),
249249
);
250-
persister
250+
fs_store
251251
.write("", "", INBOUND_PAYMENTS_FNAME, &inbound_payments.encode())
252252
.unwrap();
253253
}
@@ -684,7 +684,7 @@ fn open_channel(
684684

685685
fn send_payment(
686686
channel_manager: &ChannelManager, invoice: &Bolt11Invoice,
687-
outbound_payments: &mut PaymentInfoStorage, persister: Arc<FilesystemStore>,
687+
outbound_payments: &mut PaymentInfoStorage, fs_store: Arc<FilesystemStore>,
688688
) {
689689
let payment_hash = PaymentHash((*invoice.payment_hash()).into_inner());
690690
let payment_secret = Some(*invoice.payment_secret());
@@ -697,7 +697,7 @@ fn send_payment(
697697
amt_msat: MillisatAmount(invoice.amount_milli_satoshis()),
698698
},
699699
);
700-
persister.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
700+
fs_store.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
701701
match pay_invoice(invoice, Retry::Timeout(Duration::from_secs(10)), channel_manager) {
702702
Ok(_payment_id) => {
703703
let payee_pubkey = invoice.recover_payee_pub_key();
@@ -709,14 +709,14 @@ fn send_payment(
709709
println!("ERROR: failed to send payment: {:?}", e);
710710
print!("> ");
711711
outbound_payments.payments.get_mut(&payment_hash).unwrap().status = HTLCStatus::Failed;
712-
persister.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
712+
fs_store.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
713713
}
714714
};
715715
}
716716

717717
fn keysend<E: EntropySource>(
718718
channel_manager: &ChannelManager, payee_pubkey: PublicKey, amt_msat: u64, entropy_source: &E,
719-
outbound_payments: &mut PaymentInfoStorage, persister: Arc<FilesystemStore>,
719+
outbound_payments: &mut PaymentInfoStorage, fs_store: Arc<FilesystemStore>,
720720
) {
721721
let payment_preimage = PaymentPreimage(entropy_source.get_secure_random_bytes());
722722
let payment_hash = PaymentHash(Sha256::hash(&payment_preimage.0[..]).into_inner());
@@ -734,7 +734,7 @@ fn keysend<E: EntropySource>(
734734
amt_msat: MillisatAmount(Some(amt_msat)),
735735
},
736736
);
737-
persister.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
737+
fs_store.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
738738
match channel_manager.send_spontaneous_payment_with_retry(
739739
Some(payment_preimage),
740740
RecipientOnionFields::spontaneous_empty(),
@@ -750,7 +750,7 @@ fn keysend<E: EntropySource>(
750750
println!("ERROR: failed to send payment: {:?}", e);
751751
print!("> ");
752752
outbound_payments.payments.get_mut(&payment_hash).unwrap().status = HTLCStatus::Failed;
753-
persister.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
753+
fs_store.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
754754
}
755755
};
756756
}

src/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ async fn handle_ldk_events(
160160
channel_manager: &Arc<ChannelManager>, bitcoind_client: &BitcoindClient,
161161
network_graph: &NetworkGraph, keys_manager: &KeysManager,
162162
bump_tx_event_handler: &BumpTxEventHandler, inbound_payments: Arc<Mutex<PaymentInfoStorage>>,
163-
outbound_payments: Arc<Mutex<PaymentInfoStorage>>, persister: &Arc<FilesystemStore>,
163+
outbound_payments: Arc<Mutex<PaymentInfoStorage>>, fs_store: &Arc<FilesystemStore>,
164164
network: Network, event: Event,
165165
) {
166166
match event {
@@ -272,7 +272,7 @@ async fn handle_ldk_events(
272272
});
273273
}
274274
}
275-
persister.write("", "", INBOUND_PAYMENTS_FNAME, &inbound.encode()).unwrap();
275+
fs_store.write("", "", INBOUND_PAYMENTS_FNAME, &inbound.encode()).unwrap();
276276
}
277277
Event::PaymentSent { payment_preimage, payment_hash, fee_paid_msat, .. } => {
278278
let mut outbound = outbound_payments.lock().unwrap();
@@ -296,7 +296,7 @@ async fn handle_ldk_events(
296296
io::stdout().flush().unwrap();
297297
}
298298
}
299-
persister.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound.encode()).unwrap();
299+
fs_store.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound.encode()).unwrap();
300300
}
301301
Event::OpenChannelRequest {
302302
ref temporary_channel_id, ref counterparty_node_id, ..
@@ -345,7 +345,7 @@ async fn handle_ldk_events(
345345
let payment = outbound.payments.get_mut(&payment_hash).unwrap();
346346
payment.status = HTLCStatus::Failed;
347347
}
348-
persister.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound.encode()).unwrap();
348+
fs_store.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound.encode()).unwrap();
349349
}
350350
Event::PaymentForwarded {
351351
prev_channel_id,
@@ -433,7 +433,7 @@ async fn handle_ldk_events(
433433
let key = hex_utils::hex_str(&keys_manager.get_secure_random_bytes());
434434
// Note that if the type here changes our read code needs to change as well.
435435
let output: SpendableOutputDescriptor = output;
436-
persister.write(PENDING_SPENDABLE_OUTPUT_DIR, "", &key, &output.encode()).unwrap();
436+
fs_store.write(PENDING_SPENDABLE_OUTPUT_DIR, "", &key, &output.encode()).unwrap();
437437
}
438438
}
439439
Event::ChannelPending { channel_id, counterparty_node_id, .. } => {

0 commit comments

Comments
 (0)