X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Frouter.rs;h=15390f98ef74db04b2dd9bf2d64a9a76321f56d5;hb=e58440fe454653cedab465c495e39881fbc74aab;hp=536ec55d73ff4d9ff5fd5c9142d42aed2c5f5b0b;hpb=a252f81477c25bf1248fd9ea5269a6620187c487;p=rust-lightning diff --git a/lightning/src/ln/router.rs b/lightning/src/ln/router.rs index 536ec55d..15390f98 100644 --- a/lightning/src/ln/router.rs +++ b/lightning/src/ln/router.rs @@ -275,21 +275,6 @@ impl Readable for NetworkMap { } } -struct MutNetworkMap<'a> { - #[cfg(feature = "non_bitcoin_chain_hash_routing")] - channels: &'a mut BTreeMap<(u64, Sha256dHash), ChannelInfo>, - #[cfg(not(feature = "non_bitcoin_chain_hash_routing"))] - channels: &'a mut BTreeMap, - nodes: &'a mut BTreeMap, -} -impl NetworkMap { - fn borrow_parts(&mut self) -> MutNetworkMap { - MutNetworkMap { - channels: &mut self.channels, - nodes: &mut self.nodes, - } - } -} impl std::fmt::Display for NetworkMap { 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))?; @@ -474,7 +459,7 @@ impl RoutingMessageHandler for Router { }; let mut network_lock = self.network_map.write().unwrap(); - let network = network_lock.borrow_parts(); + let network = &mut *network_lock; let should_relay = msg.contents.excess_data.is_empty(); @@ -517,7 +502,7 @@ impl RoutingMessageHandler for Router { // b) we don't track UTXOs of channels we know about and remove them if they // get reorg'd out. // c) it's unclear how to do so without exposing ourselves to massive DoS risk. - Self::remove_channel_in_nodes(network.nodes, &entry.get(), msg.contents.short_channel_id); + Self::remove_channel_in_nodes(&mut network.nodes, &entry.get(), msg.contents.short_channel_id); *entry.get_mut() = chan_info; } else { return Err(LightningError{err: "Already have knowledge of channel", action: ErrorAction::IgnoreError})