Rename `persister` in `handle_ldk_events` to differentiate store
authorMatt Corallo <git@bluematt.me>
Sat, 30 Sep 2023 00:53:06 +0000 (00:53 +0000)
committerMatt Corallo <git@bluematt.me>
Sun, 15 Oct 2023 17:14:03 +0000 (17:14 +0000)
Since we now have a `Persist`er which is separate from our
`FilesystemStore`, its useful to use different names to
differentiate the two.

src/cli.rs
src/main.rs

index 9cb0f174fa70b3be67d13c4438e2bc011554dcb4..66af9ee6f320d0b7acc38b03fef72c598111d724 100644 (file)
@@ -65,7 +65,7 @@ pub(crate) fn poll_for_user_input(
        keys_manager: Arc<KeysManager>, network_graph: Arc<NetworkGraph>,
        onion_messenger: Arc<OnionMessenger>, inbound_payments: Arc<Mutex<PaymentInfoStorage>>,
        outbound_payments: Arc<Mutex<PaymentInfoStorage>>, ldk_data_dir: String, network: Network,
-       logger: Arc<disk::FilesystemLogger>, persister: Arc<FilesystemStore>,
+       logger: Arc<disk::FilesystemLogger>, fs_store: Arc<FilesystemStore>,
 ) {
        println!(
                "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(
                                                &channel_manager,
                                                &invoice,
                                                &mut outbound_payments.lock().unwrap(),
-                                               persister.clone(),
+                                               Arc::clone(&fs_store),
                                        );
                                }
                                "keysend" => {
@@ -209,7 +209,7 @@ pub(crate) fn poll_for_user_input(
                                                amt_msat,
                                                &*keys_manager,
                                                &mut outbound_payments.lock().unwrap(),
-                                               persister.clone(),
+                                               Arc::clone(&fs_store),
                                        );
                                }
                                "getinvoice" => {
@@ -247,7 +247,7 @@ pub(crate) fn poll_for_user_input(
                                                expiry_secs.unwrap(),
                                                Arc::clone(&logger),
                                        );
-                                       persister
+                                       fs_store
                                                .write("", "", INBOUND_PAYMENTS_FNAME, &inbound_payments.encode())
                                                .unwrap();
                                }
@@ -684,7 +684,7 @@ fn open_channel(
 
 fn send_payment(
        channel_manager: &ChannelManager, invoice: &Bolt11Invoice,
-       outbound_payments: &mut PaymentInfoStorage, persister: Arc<FilesystemStore>,
+       outbound_payments: &mut PaymentInfoStorage, fs_store: Arc<FilesystemStore>,
 ) {
        let payment_hash = PaymentHash((*invoice.payment_hash()).into_inner());
        let payment_secret = Some(*invoice.payment_secret());
@@ -697,7 +697,7 @@ fn send_payment(
                        amt_msat: MillisatAmount(invoice.amount_milli_satoshis()),
                },
        );
-       persister.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
+       fs_store.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
        match pay_invoice(invoice, Retry::Timeout(Duration::from_secs(10)), channel_manager) {
                Ok(_payment_id) => {
                        let payee_pubkey = invoice.recover_payee_pub_key();
@@ -709,14 +709,14 @@ fn send_payment(
                        println!("ERROR: failed to send payment: {:?}", e);
                        print!("> ");
                        outbound_payments.payments.get_mut(&payment_hash).unwrap().status = HTLCStatus::Failed;
-                       persister.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
+                       fs_store.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
                }
        };
 }
 
 fn keysend<E: EntropySource>(
        channel_manager: &ChannelManager, payee_pubkey: PublicKey, amt_msat: u64, entropy_source: &E,
-       outbound_payments: &mut PaymentInfoStorage, persister: Arc<FilesystemStore>,
+       outbound_payments: &mut PaymentInfoStorage, fs_store: Arc<FilesystemStore>,
 ) {
        let payment_preimage = PaymentPreimage(entropy_source.get_secure_random_bytes());
        let payment_hash = PaymentHash(Sha256::hash(&payment_preimage.0[..]).into_inner());
@@ -734,7 +734,7 @@ fn keysend<E: EntropySource>(
                        amt_msat: MillisatAmount(Some(amt_msat)),
                },
        );
-       persister.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
+       fs_store.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
        match channel_manager.send_spontaneous_payment_with_retry(
                Some(payment_preimage),
                RecipientOnionFields::spontaneous_empty(),
@@ -750,7 +750,7 @@ fn keysend<E: EntropySource>(
                        println!("ERROR: failed to send payment: {:?}", e);
                        print!("> ");
                        outbound_payments.payments.get_mut(&payment_hash).unwrap().status = HTLCStatus::Failed;
-                       persister.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
+                       fs_store.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
                }
        };
 }
index 0e0dd34439893858b3458f9ec5a4efbdbed371f5..97524e618d34665707cd6b62adb4342f3c4fe517 100644 (file)
@@ -160,7 +160,7 @@ async fn handle_ldk_events(
        channel_manager: &Arc<ChannelManager>, bitcoind_client: &BitcoindClient,
        network_graph: &NetworkGraph, keys_manager: &KeysManager,
        bump_tx_event_handler: &BumpTxEventHandler, inbound_payments: Arc<Mutex<PaymentInfoStorage>>,
-       outbound_payments: Arc<Mutex<PaymentInfoStorage>>, persister: &Arc<FilesystemStore>,
+       outbound_payments: Arc<Mutex<PaymentInfoStorage>>, fs_store: &Arc<FilesystemStore>,
        network: Network, event: Event,
 ) {
        match event {
@@ -272,7 +272,7 @@ async fn handle_ldk_events(
                                        });
                                }
                        }
-                       persister.write("", "", INBOUND_PAYMENTS_FNAME, &inbound.encode()).unwrap();
+                       fs_store.write("", "", INBOUND_PAYMENTS_FNAME, &inbound.encode()).unwrap();
                }
                Event::PaymentSent { payment_preimage, payment_hash, fee_paid_msat, .. } => {
                        let mut outbound = outbound_payments.lock().unwrap();
@@ -296,7 +296,7 @@ async fn handle_ldk_events(
                                        io::stdout().flush().unwrap();
                                }
                        }
-                       persister.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound.encode()).unwrap();
+                       fs_store.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound.encode()).unwrap();
                }
                Event::OpenChannelRequest {
                        ref temporary_channel_id, ref counterparty_node_id, ..
@@ -345,7 +345,7 @@ async fn handle_ldk_events(
                                let payment = outbound.payments.get_mut(&payment_hash).unwrap();
                                payment.status = HTLCStatus::Failed;
                        }
-                       persister.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound.encode()).unwrap();
+                       fs_store.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound.encode()).unwrap();
                }
                Event::PaymentForwarded {
                        prev_channel_id,
@@ -433,7 +433,7 @@ async fn handle_ldk_events(
                                let key = hex_utils::hex_str(&keys_manager.get_secure_random_bytes());
                                // Note that if the type here changes our read code needs to change as well.
                                let output: SpendableOutputDescriptor = output;
-                               persister.write(PENDING_SPENDABLE_OUTPUT_DIR, "", &key, &output.encode()).unwrap();
+                               fs_store.write(PENDING_SPENDABLE_OUTPUT_DIR, "", &key, &output.encode()).unwrap();
                        }
                }
                Event::ChannelPending { channel_id, counterparty_node_id, .. } => {