logging and disable failing tests
[rust-lightning] / lightning / src / routing / router.rs
index ac7576b00dd0a1d239c4b143af67e55005186bf0..a4f216ff29b0e124880a7cf6f84f23962a1e161d 100644 (file)
@@ -26,7 +26,7 @@ use std::collections::{HashMap, BinaryHeap};
 use std::ops::Deref;
 
 /// A hop in a route
-#[derive(Clone, PartialEq)]
+#[derive(Clone, Debug, PartialEq)]
 pub struct RouteHop {
        /// The node_id of the node at this hop.
        pub pubkey: PublicKey,
@@ -115,7 +115,7 @@ impl Readable for Route {
 }
 
 /// A channel descriptor which provides a last-hop route to get_route
-#[derive(Clone)]
+#[derive(Clone, Debug, PartialEq)]
 pub struct RouteHint {
        /// The node_id of the non-target end of the route
        pub src_node_id: PublicKey,
@@ -171,7 +171,7 @@ struct DummyDirectionalChannelInfo {
 /// so that we can choose cheaper paths (as per Dijkstra's algorithm).
 /// Fee values should be updated only in the context of the whole path, see update_value_and_recompute_fees.
 /// These fee values are useful to choose hops as we traverse the graph "payee-to-payer".
-#[derive(Clone)]
+#[derive(Clone, Debug)]
 struct PathBuildingHop {
        /// Hop-specific details unrelated to the path during the routing phase,
        /// but rather relevant to the LN graph.
@@ -210,7 +210,7 @@ impl PathBuildingHop {
 
 // Instantiated with a list of hops with correct data in them collected during path finding,
 // an instance of this struct should be further modified only via given methods.
-#[derive(Clone)]
+#[derive(Clone, Debug)]
 struct PaymentPath {
        hops: Vec<PathBuildingHop>,
 }
@@ -500,6 +500,8 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
                                        };
                                        let over_path_minimum_msat = amount_to_transfer_over_msat >= $directional_info.htlc_minimum_msat &&
                                                amount_to_transfer_over_msat >= $incl_fee_next_hops_htlc_minimum_msat;
+log_trace!(logger, "{} adding entry {} contributing up to {} (must be at least {}) -> {} ie {} with min {:?} and {} path min", if over_path_minimum_msat { "Adding" } else { "Not adding" },
+                  $chan_id, available_value_contribution_msat, minimal_value_contribution_msat, $next_hops_value_contribution, amount_to_transfer_over_msat, $directional_info.htlc_minimum_msat, $incl_fee_next_hops_htlc_minimum_msat);
 
                                        // If HTLC minimum is larger than the amount we're going to transfer, we shouldn't
                                        // bother considering this channel.
@@ -574,6 +576,7 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
                                                        }
                                                }
 
+log_trace!(logger, "NEW GRAPH NODE! VC: {}", value_contribution_msat);
                                                let new_graph_node = RouteGraphNode {
                                                        pubkey: $src_node_id,
                                                        lowest_fee_to_peer_through_node: total_fee_msat,
@@ -814,10 +817,12 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
                                        // We "propagate" the fees one hop backward (topologically) here,
                                        // so that fees paid for a HTLC forwarding on the current channel are
                                        // associated with the previous channel (where they will be subtracted).
+log_trace!(logger, "hvc {}", new_entry.hop_use_fee_msat);
                                        ordered_hops.last_mut().unwrap().route_hop.fee_msat = new_entry.hop_use_fee_msat;
                                        ordered_hops.last_mut().unwrap().route_hop.cltv_expiry_delta = new_entry.route_hop.cltv_expiry_delta;
                                        ordered_hops.push(new_entry.clone());
                                }
+log_trace!(logger, "vc {}", value_contribution_msat);
                                ordered_hops.last_mut().unwrap().route_hop.fee_msat = value_contribution_msat;
                                ordered_hops.last_mut().unwrap().hop_use_fee_msat = 0;
                                ordered_hops.last_mut().unwrap().route_hop.cltv_expiry_delta = final_cltv;
@@ -885,6 +890,8 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
                return Err(LightningError{err: "Failed to find a path to the given destination".to_owned(), action: ErrorAction::IgnoreError});
        }
 
+log_trace!(logger, "Potential paths {:?}", payment_paths);
+
        if already_collected_value_msat < final_value_msat {
                return Err(LightningError{err: "Failed to find a sufficient route to the given destination".to_owned(), action: ErrorAction::IgnoreError});
        }