X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-net-tokio%2Fsrc%2Flib.rs;h=a9fd861bc846e440fd8ff54ab31deedf622aa8e6;hb=e6300dab2dca2fb997b02fe37d678732a97b116a;hp=62c036b9796c96f2f812e8eb162835ca9ffd57ba;hpb=001bc7113a92a586e7e7ac4557bbae7a1a402550;p=rust-lightning diff --git a/lightning-net-tokio/src/lib.rs b/lightning-net-tokio/src/lib.rs index 62c036b9..a9fd861b 100644 --- a/lightning-net-tokio/src/lib.rs +++ b/lightning-net-tokio/src/lib.rs @@ -69,6 +69,8 @@ #![deny(broken_intra_doc_links)] #![deny(missing_docs)] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] + use bitcoin::secp256k1::key::PublicKey; use tokio::net::TcpStream; @@ -79,10 +81,11 @@ use tokio::io::{AsyncReadExt, AsyncWrite, AsyncWriteExt}; use lightning::ln::peer_handler; use lightning::ln::peer_handler::SocketDescriptor as LnSocketTrait; use lightning::ln::peer_handler::CustomMessageHandler; -use lightning::ln::msgs::{ChannelMessageHandler, RoutingMessageHandler}; +use lightning::ln::msgs::{ChannelMessageHandler, RoutingMessageHandler, NetAddress}; use lightning::util::logger::Logger; use std::task; +use std::net::IpAddr; use std::net::SocketAddr; use std::net::TcpStream as StdTcpStream; use std::sync::{Arc, Mutex}; @@ -220,11 +223,21 @@ pub fn setup_inbound(peer_manager: Arc Some(NetAddress::IPv4 { + addr: ip.octets(), + port: ip_addr.port(), + }), + IpAddr::V6(ip) => Some(NetAddress::IPv6 { + addr: ip.octets(), + port: ip_addr.port(), + }), + }) { Some(tokio::spawn(Connection::schedule_read(peer_manager, us, reader, read_receiver, write_receiver))) } else { // Note that we will skip socket_disconnected here, in accordance with the PeerManager @@ -261,11 +274,20 @@ pub fn setup_outbound(peer_manager: Arc Some(NetAddress::IPv4 { + addr: ip.octets(), + port: ip_addr.port(), + }), + IpAddr::V6(ip) => Some(NetAddress::IPv6 { + addr: ip.octets(), + port: ip_addr.port(), + }), + }) { Some(tokio::spawn(async move { // We should essentially always have enough room in a TCP socket buffer to send the // initial 10s of bytes. However, tokio running in single-threaded mode will always @@ -494,7 +516,7 @@ mod tests { fn handle_channel_update(&self, _msg: &ChannelUpdate) -> Result { Ok(false) } fn get_next_channel_announcements(&self, _starting_point: u64, _batch_amount: u8) -> Vec<(ChannelAnnouncement, Option, Option)> { Vec::new() } fn get_next_node_announcements(&self, _starting_point: Option<&PublicKey>, _batch_amount: u8) -> Vec { Vec::new() } - fn sync_routing_table(&self, _their_node_id: &PublicKey, _init_msg: &Init) { } + fn peer_connected(&self, _their_node_id: &PublicKey, _init_msg: &Init) { } fn handle_reply_channel_range(&self, _their_node_id: &PublicKey, _msg: ReplyChannelRange) -> Result<(), LightningError> { Ok(()) } fn handle_reply_short_channel_ids_end(&self, _their_node_id: &PublicKey, _msg: ReplyShortChannelIdsEnd) -> Result<(), LightningError> { Ok(()) } fn handle_query_channel_range(&self, _their_node_id: &PublicKey, _msg: QueryChannelRange) -> Result<(), LightningError> { Ok(()) }