Split inbound+outbound payments, use PaymentId as outbound key
[ldk-sample] / src / disk.rs
index 77cefd6d59a91bc25f26c855d9119235c62df78c..d301180d605202690aa24dd96bbf1bfa2c18d7c2 100644 (file)
@@ -1,8 +1,8 @@
-use crate::{cli, NetworkGraph, PaymentInfoStorage};
+use crate::{cli, InboundPaymentInfoStorage, NetworkGraph, OutboundPaymentInfoStorage};
 use bitcoin::secp256k1::PublicKey;
 use bitcoin::Network;
 use chrono::Utc;
-use lightning::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringParameters};
+use lightning::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringDecayParameters};
 use lightning::util::logger::{Logger, Record};
 use lightning::util::ser::{Readable, ReadableArgs, Writer};
 use std::collections::HashMap;
@@ -86,19 +86,28 @@ pub(crate) fn read_network(
        NetworkGraph::new(network, logger)
 }
 
-pub(crate) fn read_payment_info(path: &Path) -> PaymentInfoStorage {
+pub(crate) fn read_inbound_payment_info(path: &Path) -> InboundPaymentInfoStorage {
        if let Ok(file) = File::open(path) {
-               if let Ok(info) = PaymentInfoStorage::read(&mut BufReader::new(file)) {
+               if let Ok(info) = InboundPaymentInfoStorage::read(&mut BufReader::new(file)) {
                        return info;
                }
        }
-       PaymentInfoStorage { payments: HashMap::new() }
+       InboundPaymentInfoStorage { payments: HashMap::new() }
+}
+
+pub(crate) fn read_outbound_payment_info(path: &Path) -> OutboundPaymentInfoStorage {
+       if let Ok(file) = File::open(path) {
+               if let Ok(info) = OutboundPaymentInfoStorage::read(&mut BufReader::new(file)) {
+                       return info;
+               }
+       }
+       OutboundPaymentInfoStorage { payments: HashMap::new() }
 }
 
 pub(crate) fn read_scorer(
        path: &Path, graph: Arc<NetworkGraph>, logger: Arc<FilesystemLogger>,
 ) -> ProbabilisticScorer<Arc<NetworkGraph>, Arc<FilesystemLogger>> {
-       let params = ProbabilisticScoringParameters::default();
+       let params = ProbabilisticScoringDecayParameters::default();
        if let Ok(file) = File::open(path) {
                let args = (params.clone(), Arc::clone(&graph), Arc::clone(&logger));
                if let Ok(scorer) = ProbabilisticScorer::read(&mut BufReader::new(file), args) {