impl std::fmt::Display for DirectionalChannelInfo {
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
- write!(f, " node id {} last_update {} enabled {} cltv_expiry_delta {} htlc_minimum_msat {} fee_base_msat {} fee_proportional_millionths {}\n", log_pubkey!(self.src_node_id), self.last_update, self.enabled, self.cltv_expiry_delta, self.htlc_minimum_msat, self.fee_base_msat, self.fee_proportional_millionths)?;
+ write!(f, "src_node_id {}, last_update {}, enabled {}, cltv_expiry_delta {}, htlc_minimum_msat {}, fee_base_msat {}, fee_proportional_millionths {}", log_pubkey!(self.src_node_id), self.last_update, self.enabled, self.cltv_expiry_delta, self.htlc_minimum_msat, self.fee_base_msat, self.fee_proportional_millionths)?;
Ok(())
}
}
impl std::fmt::Display for ChannelInfo {
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
- //TODO: GlobalFeatures
- write!(f, " one_to_two {}", self.one_to_two)?;
- write!(f, " two_to_one {}", self.two_to_one)?;
+ write!(f, "features: {}, one_to_two: {}, two_to_one: {}", log_bytes!(self.features.encode()), self.one_to_two, self.two_to_one)?;
Ok(())
}
}
impl std::fmt::Display for NodeInfo {
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
- write!(f, " Channels\n")?;
- for c in self.channels.iter() {
- write!(f, " {}\n", c)?;
- }
- write!(f, " lowest_inbound_channel_fee_base_msat {}\n", self.lowest_inbound_channel_fee_base_msat)?;
- write!(f, " lowest_inbound_channel_fee_proportional_millionths {}\n", self.lowest_inbound_channel_fee_proportional_millionths)?;
- //TODO: GlobalFeatures, last_update, rgb, alias, addresses
+ write!(f, "features: {}, last_update: {}, lowest_inbound_channel_fee_base_msat: {}, lowest_inbound_channel_fee_proportional_millionths: {}, channels: {:?}", log_bytes!(self.features.encode()), self.last_update, self.lowest_inbound_channel_fee_base_msat, self.lowest_inbound_channel_fee_proportional_millionths, &self.channels[..])?;
Ok(())
}
}
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
write!(f, "Node id {} network map\n[Channels]\n", log_pubkey!(self.our_node_id))?;
for (key, val) in self.channels.iter() {
- write!(f, " {} :\n {}\n", key, val)?;
+ write!(f, " {}: {}\n", key, val)?;
}
write!(f, "[Nodes]\n")?;
for (key, val) in self.nodes.iter() {
- write!(f, " {} :\n {}\n", log_pubkey!(key), val)?;
+ write!(f, " {}: {}\n", log_pubkey!(key), val)?;
}
Ok(())
}
}
}
+ /// Dumps the entire network view of this Router to the logger provided in the constructor at
+ /// level Trace
+ pub fn trace_state(&self) {
+ log_trace!(self, "{}", self.network_map.read().unwrap());
+ }
+
/// Get network addresses by node id
pub fn get_addresses(&self, pubkey: &PublicKey) -> Option<Vec<NetAddress>> {
let network = self.network_map.read().unwrap();
}
res.last_mut().unwrap().fee_msat = final_value_msat;
res.last_mut().unwrap().cltv_expiry_delta = final_cltv;
- return Ok(Route {
- hops: res
- });
+ let route = Route { hops: res };
+ log_trace!(self, "Got route: {}", log_route!(route));
+ return Ok(route);
}
match network.nodes.get(&pubkey) {
}
}
-pub(crate) struct DebugBytes<'a>(pub &'a [u8; 32]);
+pub(crate) struct DebugBytes<'a>(pub &'a [u8]);
impl<'a> std::fmt::Display for DebugBytes<'a> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
for i in self.0 {
}
}
-#[allow(dead_code)]
pub(crate) struct DebugRoute<'a>(pub &'a Route);
impl<'a> std::fmt::Display for DebugRoute<'a> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
- for (i,h) in self.0.hops.iter().enumerate() {
- write!(f, "Hop {}\n pubkey {}\n short_channel_id {}\n fee_msat {}\n cltv_expiry_delta {}\n\n", i, log_pubkey!(h.pubkey), h.short_channel_id, h.fee_msat, h.cltv_expiry_delta)?;
+ for h in self.0.hops.iter() {
+ write!(f, "node_id: {}, short_channel_id: {}, fee_msat: {}, cltv_expiry_delta: {}\n", log_pubkey!(h.pubkey), h.short_channel_id, h.fee_msat, h.cltv_expiry_delta)?;
}
Ok(())
}
}
-#[allow(unused_macros)]
macro_rules! log_route {
($obj: expr) => {
::util::macro_logger::DebugRoute(&$obj)