Merge pull request #522 from valentinewallace/chanmgr-fee-est-arc-to-deref
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Fri, 28 Feb 2020 19:08:43 +0000 (19:08 +0000)
committerGitHub <noreply@github.com>
Fri, 28 Feb 2020 19:08:43 +0000 (19:08 +0000)
Update ChannelManager's FeeEstimator from Arc to Deref.

1  2 
lightning/src/ln/peer_handler.rs

index 29e67e6ba999e054b123927fdf4538099b5bb096,ead00a5e9153a1be72d6588e3500fe60135020fc..60df3d80196698234146400260411ef5f4a70b2e
@@@ -162,7 -162,7 +162,7 @@@ fn _check_usize_is_32_or_64() 
  /// lifetimes). Other times you can afford a reference, which is more efficient, in which case
  /// SimpleRefPeerManager is the more appropriate type. Defining these type aliases prevents
  /// issues such as overly long function definitions.
- pub type SimpleArcPeerManager<SD, M, T> = Arc<PeerManager<SD, SimpleArcChannelManager<M, T>>>;
+ pub type SimpleArcPeerManager<SD, M, T, F> = Arc<PeerManager<SD, SimpleArcChannelManager<M, T, F>>>;
  
  /// SimpleRefPeerManager is a type alias for a PeerManager reference, and is the reference
  /// counterpart to the SimpleArcPeerManager type alias. Use this type by default when you don't
  /// usage of lightning-net-tokio (since tokio::spawn requires parameters with static lifetimes).
  /// But if this is not necessary, using a reference is more efficient. Defining these type aliases
  /// helps with issues such as long function definitions.
- pub type SimpleRefPeerManager<'a, 'b, 'c, SD, M, T> = PeerManager<SD, SimpleRefChannelManager<'a, 'b, 'c, M, T>>;
+ pub type SimpleRefPeerManager<'a, 'b, 'c, 'd, SD, M, T, F> = PeerManager<SD, SimpleRefChannelManager<'a, 'b, 'c, 'd, M, T, F>>;
  
  /// A PeerManager manages a set of peers, described by their SocketDescriptor and marshalls socket
  /// events into messages which it passes on to its MessageHandlers.
@@@ -755,13 -755,10 +755,13 @@@ impl<Descriptor: SocketDescriptor, CM: 
  
                                                                                        // Unknown messages:
                                                                                        wire::Message::Unknown(msg_type) if msg_type.is_even() => {
 +                                                                                              log_debug!(self, "Received unknown even message of type {}, disconnecting peer!", msg_type);
                                                                                                // Fail the channel if message is an even, unknown type as per BOLT #1.
                                                                                                return Err(PeerHandleError{ no_connection_possible: true });
                                                                                        },
 -                                                                                      wire::Message::Unknown(_) => {},
 +                                                                                      wire::Message::Unknown(msg_type) => {
 +                                                                                              log_trace!(self, "Received unknown odd message of type {}, ignoring", msg_type);
 +                                                                                      },
                                                                                }
                                                                        }
                                                                }
                                        descriptors_needing_disconnect.push(descriptor.clone());
                                        match peer.their_node_id {
                                                Some(node_id) => {
 +                                                      log_trace!(self, "Disconnecting peer with id {} due to ping timeout", node_id);
                                                        node_id_to_descriptor.remove(&node_id);
 -                                                      self.message_handler.chan_handler.peer_disconnected(&node_id, true);
 +                                                      self.message_handler.chan_handler.peer_disconnected(&node_id, false);
                                                }
 -                                              None => {}
 +                                              None => {
 +                                                      // This can't actually happen as we should have hit
 +                                                      // is_ready_for_encryption() previously on this same peer.
 +                                                      unreachable!();
 +                                              },
                                        }
                                        return false;
                                }