From: Matt Corallo Date: Fri, 9 Nov 2018 01:55:20 +0000 (+1030) Subject: F X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=b46c3cc57e1339ae6ae5b900d327a7e6804672ec;p=rust-lightning F --- diff --git a/src/ln/msgs.rs b/src/ln/msgs.rs index c25ce8805..354376649 100644 --- a/src/ln/msgs.rs +++ b/src/ln/msgs.rs @@ -334,7 +334,7 @@ pub struct AnnouncementSignatures { } /// An address which can be used to connect to a remote peer -#[derive(Clone, PartialEq)] +#[derive(Clone)] pub enum NetAddress { /// An IPv4 address/port on which the peer is listenting. IPv4 { @@ -381,7 +381,8 @@ impl NetAddress { } } } -#[derive(Clone, PartialEq)] + +#[derive(Clone)] // Only exposed as broadcast of node_announcement should be filtered by node_id /// The unsigned part of a node_announcement pub struct UnsignedNodeAnnouncement { @@ -398,7 +399,7 @@ pub struct UnsignedNodeAnnouncement { pub(crate) excess_address_data: Vec, pub(crate) excess_data: Vec, } -#[derive(Clone, PartialEq)] +#[derive(Clone)] /// A node_announcement message to be sent or received from a peer pub struct NodeAnnouncement { pub(crate) signature: Signature, @@ -575,18 +576,6 @@ pub trait ChannelMessageHandler : events::MessageSendEventsProvider + Send + Syn /// Handle an incoming error message from the given peer. fn handle_error(&self, their_node_id: &PublicKey, msg: &ErrorMessage); } -#[derive(PartialEq)] -///Enum used to keep track of syncing information/state of peer and if a sync is required -pub enum InitSyncTracker{ - ///This indicates if a sync is required or not, false is no sync required, true is sync required but not started - Sync(bool), - ///This is the last synced node's public key - ///During this state it is syncing nodes - NodeCounter(PublicKey), - ///This is the last synced channel _id - ///During this state it is syncing nodes - ChannelCounter(u64), -} /// A trait to describe an object which can receive routing messages. pub trait RoutingMessageHandler : Send + Sync { @@ -601,12 +590,14 @@ pub trait RoutingMessageHandler : Send + Sync { fn handle_channel_update(&self, msg: &ChannelUpdate) -> Result; /// Handle some updates to the route graph that we learned due to an outbound failed payment. fn handle_htlc_fail_channel_update(&self, update: &HTLCFailChannelUpdate); - ///Gets a subset of the channel announcements and updates required to dump our routing table to a remote node, starting at the short_channel_id indicated by starting_point.channelcounter and including batch_amount entries - /// This function will start iterating at 0 if the starting_point is < 0. - fn get_next_channel_announcements(&self, starting_point: &mut InitSyncTracker, batch_amount: u8)->(Vec<(ChannelAnnouncement, ChannelUpdate,ChannelUpdate)>); - ///Gets a subset of the node announcements required to dump our routing table to a remote node, starting at the PublicKey indicated by starting_point.nodecounter and including batch_amount entries - /// This function will start iterating at 0 if the starting_point is < 0. - fn get_next_node_announcements(&self, starting_point: &mut InitSyncTracker, batch_amount: u8)->(Vec); + /// Gets a subset of the channel announcements and updates required to dump our routing table + /// to a remote node, starting at the short_channel_id indicated by starting_point and + /// including batch_amount entries. + fn get_next_channel_announcements(&self, starting_point: u64, batch_amount: u8) -> Vec<(ChannelAnnouncement, ChannelUpdate, ChannelUpdate)>; + /// Gets a subset of the node announcements required to dump our routing table to a remote node, + /// starting at the node *after* the provided publickey and including batch_amount entries. + /// If None is provided for starting_point, we start at the first node. + fn get_next_node_announcements(&self, starting_point: Option<&PublicKey>, batch_amount: u8) -> Vec; } pub(crate) struct OnionRealm0HopData { diff --git a/src/ln/peer_handler.rs b/src/ln/peer_handler.rs index 90e2f9193..87a2e6d1c 100644 --- a/src/ln/peer_handler.rs +++ b/src/ln/peer_handler.rs @@ -88,6 +88,12 @@ impl error::Error for PeerHandleError { } } +enum InitSyncTracker{ + NoSyncRequested, + ChannelsSyncing(u64), + NodesSyncing(PublicKey), +} + struct Peer { channel_encryptor: PeerChannelEncryptor, outbound: bool, @@ -102,22 +108,22 @@ struct Peer { pending_read_buffer: Vec, pending_read_buffer_pos: usize, pending_read_is_header: bool, - sync_status : msgs::InitSyncTracker, + + sync_status: InitSyncTracker, } impl Peer { - pub fn require_sync(&self)->bool{ - if let msgs::InitSyncTracker::Sync(i) = self.sync_status {i} else {false} - } - - /// this function checks if the the channel announcements and updates are allowed to be forwarded to a specific peer. - /// If the peer is in syncing state and the channel_id has not been synced then the function returns false as this info will forward at a later stage and - /// we dont want to send duplicate messages. If the channel was already synced then we can forward those messages and the function will then return true. - pub fn is_channel_allowed_to_forward(&self, channel_id : u64)->bool{ + /// Returns true if the the channel announcements/updates for the given channel should be + /// forwarded to this peer. + /// If we are sending our routing table to this peer and we have not yet sent channel + /// announcements/updates for the given channel_id then we will send it when we get to that + /// point and we shouldn't send it yet to avoid sending duplicate updates. If we've already + /// sent the old versions, we should send the update, and so return true here. + fn should_forward_channel(&self, channel_id: u64)->bool{ match self.sync_status { - msgs::InitSyncTracker::Sync(i) => !i, - msgs::InitSyncTracker::NodeCounter(_i) => false, - msgs::InitSyncTracker::ChannelCounter(i) => (i < channel_id), + InitSyncTracker::NoSyncRequested => true, + InitSyncTracker::ChannelsSyncing(i) => i < channel_id, + InitSyncTracker::NodesSyncing(_) => true, } } } @@ -239,7 +245,8 @@ impl PeerManager { pending_read_buffer: pending_read_buffer, pending_read_buffer_pos: 0, pending_read_is_header: false, - sync_status : msgs::InitSyncTracker::Sync(false), + + sync_status: InitSyncTracker::NoSyncRequested, }).is_some() { panic!("PeerManager driver duplicated descriptors!"); }; @@ -274,7 +281,8 @@ impl PeerManager { pending_read_buffer: pending_read_buffer, pending_read_buffer_pos: 0, pending_read_is_header: false, - sync_status : msgs::InitSyncTracker::Sync(false), + + sync_status: InitSyncTracker::NoSyncRequested, }).is_some() { panic!("PeerManager driver duplicated descriptors!"); }; @@ -285,36 +293,63 @@ impl PeerManager { macro_rules! encode_and_send_msg { ($msg: expr, $msg_code: expr) => { { - log_trace!(self, "Encoding and sending message of type {} to {}", $msg_code, log_pubkey!(peer.their_node_id.unwrap())); + log_trace!(self, "Encoding and sending sync update message of type {} to {}", $msg_code, log_pubkey!(peer.their_node_id.unwrap())); peer.pending_outbound_buffer.push_back(peer.channel_encryptor.encrypt_message(&encode_msg!($msg, $msg_code)[..])); } } } + const MSG_BUFF_SIZE: usize = 10; while !peer.awaiting_write_event { - if { - let should_be_reading = peer.pending_outbound_buffer.len() < 10; - if (peer.require_sync()) &&(should_be_reading){ - match peer.sync_status{ - msgs::InitSyncTracker::ChannelCounter(_c) => { - let all_messages_tuple = self.message_handler.route_handler.get_next_channel_announcements(&mut peer.sync_status,(10-peer.pending_outbound_buffer.len()) as u8); - for tuple in all_messages_tuple.iter(){ - encode_and_send_msg!(tuple.0, 256); - encode_and_send_msg!(tuple.1, 258); - encode_and_send_msg!(tuple.2, 258); + if peer.pending_outbound_buffer.len() < MSG_BUFF_SIZE { + match peer.sync_status { + InitSyncTracker::NoSyncRequested => {}, + InitSyncTracker::ChannelsSyncing(c) if c < 0xffff_ffff_ffff_ffff => { + let steps = ((MSG_BUFF_SIZE - peer.pending_outbound_buffer.len() + 2) / 3) as u8; + let all_messages = self.message_handler.route_handler.get_next_channel_announcements(0, steps); + for &(ref announce, ref update_a, ref update_b) in all_messages.iter() { + encode_and_send_msg!(announce, 256); + encode_and_send_msg!(update_a, 258); + encode_and_send_msg!(update_b, 258); + peer.sync_status = InitSyncTracker::ChannelsSyncing(announce.contents.short_channel_id + 1); } - }, - _=>{let all_messages = self.message_handler.route_handler.get_next_node_announcements(&mut peer.sync_status,(10-peer.pending_outbound_buffer.len()) as u8); - for message in all_messages.iter(){ - encode_and_send_msg!(message, 256); - }}, - }; + if all_messages.is_empty() || all_messages.len() != steps as usize { + peer.sync_status = InitSyncTracker::ChannelsSyncing(0xffff_ffff_ffff_ffff); + } + }, + InitSyncTracker::ChannelsSyncing(c) if c == 0xffff_ffff_ffff_ffff => { + let steps = (MSG_BUFF_SIZE - peer.pending_outbound_buffer.len()) as u8; + let all_messages = self.message_handler.route_handler.get_next_node_announcements(None, steps); + for msg in all_messages.iter() { + encode_and_send_msg!(msg, 256); + peer.sync_status = InitSyncTracker::NodesSyncing(msg.contents.node_id); + } + if all_messages.is_empty() || all_messages.len() != steps as usize { + peer.sync_status = InitSyncTracker::NoSyncRequested; + } + }, + InitSyncTracker::ChannelsSyncing(_) => unreachable!(), + InitSyncTracker::NodesSyncing(key) => { + let steps = (MSG_BUFF_SIZE - peer.pending_outbound_buffer.len()) as u8; + let all_messages = self.message_handler.route_handler.get_next_node_announcements(Some(&key), steps); + for msg in all_messages.iter() { + encode_and_send_msg!(msg, 256); + peer.sync_status = InitSyncTracker::NodesSyncing(msg.contents.node_id); + } + if all_messages.is_empty() || all_messages.len() != steps as usize { + peer.sync_status = InitSyncTracker::NoSyncRequested; + } + }, } + } + + if { let next_buff = match peer.pending_outbound_buffer.front() { None => return, Some(buff) => buff, }; - let data_sent = descriptor.send_data(&next_buff, peer.pending_outbound_buffer_first_msg_offset, should_be_reading); + let should_be_reading = peer.pending_outbound_buffer.len() < MSG_BUFF_SIZE; + let data_sent = descriptor.send_data(next_buff, peer.pending_outbound_buffer_first_msg_offset, should_be_reading); peer.pending_outbound_buffer_first_msg_offset += data_sent; if peer.pending_outbound_buffer_first_msg_offset == next_buff.len() { true } else { false } } { @@ -567,7 +602,7 @@ impl PeerManager { if msg.global_features.supports_unknown_bits() { "present" } else { "none" }); if msg.local_features.initial_routing_sync() { - peer.sync_status = msgs::InitSyncTracker::Sync(true); + peer.sync_status = InitSyncTracker::ChannelsSyncing(0); peers.peers_needing_send.insert(peer_descriptor.clone()); } peer.their_global_features = Some(msg.global_features); @@ -915,7 +950,8 @@ impl PeerManager { let encoded_update_msg = encode_msg!(update_msg, 258); for (ref descriptor, ref mut peer) in peers.peers.iter_mut() { - if !peer.channel_encryptor.is_ready_for_encryption() || peer.their_global_features.is_none() ||!peer.is_channel_allowed_to_forward(msg.contents.short_channel_id) { + if !peer.channel_encryptor.is_ready_for_encryption() || peer.their_global_features.is_none() || + !peer.should_forward_channel(msg.contents.short_channel_id) { continue } match peer.their_node_id { @@ -938,7 +974,8 @@ impl PeerManager { let encoded_msg = encode_msg!(msg, 258); for (ref descriptor, ref mut peer) in peers.peers.iter_mut() { - if !peer.channel_encryptor.is_ready_for_encryption() || peer.their_global_features.is_none() || !peer.is_channel_allowed_to_forward(msg.contents.short_channel_id) { + if !peer.channel_encryptor.is_ready_for_encryption() || peer.their_global_features.is_none() || + !peer.should_forward_channel(msg.contents.short_channel_id) { continue } peer.pending_outbound_buffer.push_back(peer.channel_encryptor.encrypt_message(&encoded_msg[..])); diff --git a/src/ln/router.rs b/src/ln/router.rs index ba04011a2..3476e201e 100644 --- a/src/ln/router.rs +++ b/src/ln/router.rs @@ -13,14 +13,14 @@ use bitcoin::blockdata::opcodes; use chain::chaininterface::{ChainError, ChainWatchInterface}; use ln::channelmanager; -use ln::msgs::{DecodeError,ErrorAction,HandleError,RoutingMessageHandler,NetAddress,GlobalFeatures, InitSyncTracker}; +use ln::msgs::{DecodeError,ErrorAction,HandleError,RoutingMessageHandler,NetAddress,GlobalFeatures}; use ln::msgs; use util::ser::{Writeable, Readable}; use util::logger::Logger; use std::cmp; use std::sync::{RwLock,Arc}; -use std::collections::{HashMap,BinaryHeap, BTreeMap}; +use std::collections::{HashMap,BinaryHeap,BTreeMap}; use std::collections::btree_map::Entry as BtreeEntry; use std; @@ -86,7 +86,7 @@ struct DirectionalChannelInfo { htlc_minimum_msat: u64, fee_base_msat: u32, fee_proportional_millionths: u32, - last_update_message : Option, + last_update_message: Option, } impl std::fmt::Display for DirectionalChannelInfo { @@ -102,7 +102,7 @@ struct ChannelInfo { two_to_one: DirectionalChannelInfo, //this is cached here so we can send out it later if required by route_init_sync //keep an eye on this to see if the extra memory is a problem - announcement_message : Option, + announcement_message: Option, } impl std::fmt::Display for ChannelInfo { @@ -112,7 +112,6 @@ impl std::fmt::Display for ChannelInfo { } } -#[derive(PartialEq)] struct NodeInfo { #[cfg(feature = "non_bitcoin_chain_hash_routing")] channels: Vec<(u64, Sha256dHash)>, @@ -129,7 +128,7 @@ struct NodeInfo { addresses: Vec, //this is cached here so we can send out it later if required by route_init_sync //keep an eye on this to see if the extra memory is a problem - announcement_message : Option, + announcement_message: Option, } impl std::fmt::Display for NodeInfo { @@ -260,14 +259,10 @@ impl RoutingMessageHandler for Router { node.rgb = msg.contents.rgb; node.alias = msg.contents.alias; node.addresses = msg.contents.addresses.clone(); - node.announcement_message = if msg.contents.excess_data.is_empty(){ - Some(msg.clone()) - } - else{ - None - }; - Ok(msg.contents.excess_data.is_empty() && msg.contents.excess_address_data.is_empty() && !msg.contents.features.supports_unknown_bits()) + let should_relay = msg.contents.excess_data.is_empty() && msg.contents.excess_address_data.is_empty() && !msg.contents.features.supports_unknown_bits(); + node.announcement_message = if should_relay { Some(msg.clone()) } else { None }; + Ok(should_relay) } } } @@ -315,6 +310,8 @@ impl RoutingMessageHandler for Router { let mut network_lock = self.network_map.write().unwrap(); let network = network_lock.borrow_parts(); + let should_relay = msg.contents.excess_data.is_empty() && !msg.contents.features.supports_unknown_bits(); + let chan_info = ChannelInfo { features: msg.contents.features.clone(), one_to_two: DirectionalChannelInfo { @@ -325,7 +322,7 @@ impl RoutingMessageHandler for Router { htlc_minimum_msat: u64::max_value(), fee_base_msat: u32::max_value(), fee_proportional_millionths: u32::max_value(), - last_update_message : None, + last_update_message: None, }, two_to_one: DirectionalChannelInfo { src_node_id: msg.contents.node_id_2.clone(), @@ -335,14 +332,9 @@ impl RoutingMessageHandler for Router { htlc_minimum_msat: u64::max_value(), fee_base_msat: u32::max_value(), fee_proportional_millionths: u32::max_value(), - last_update_message : None, - }, - announcement_message : if msg.contents.excess_data.is_empty(){ - Some(msg.clone()) - } - else{ - None + last_update_message: None, }, + announcement_message: if should_relay { Some(msg.clone()) } else { None }, }; match network.channels.entry(NetworkMap::get_key(msg.contents.short_channel_id, msg.contents.chain_hash)) { @@ -396,7 +388,7 @@ impl RoutingMessageHandler for Router { add_channel_to_node!(msg.contents.node_id_1); add_channel_to_node!(msg.contents.node_id_2); - Ok(msg.contents.excess_data.is_empty() && !msg.contents.features.supports_unknown_bits()) + Ok(should_relay) } fn handle_htlc_fail_channel_update(&self, update: &msgs::HTLCFailChannelUpdate) { @@ -448,11 +440,10 @@ impl RoutingMessageHandler for Router { $target.htlc_minimum_msat = msg.contents.htlc_minimum_msat; $target.fee_base_msat = msg.contents.fee_base_msat; $target.fee_proportional_millionths = msg.contents.fee_proportional_millionths; - $target.last_update_message = if msg.contents.excess_data.is_empty(){ + $target.last_update_message = if msg.contents.excess_data.is_empty() { Some(msg.clone()) - } - else{ - None + } else { + None }; } } @@ -502,49 +493,48 @@ impl RoutingMessageHandler for Router { } - fn get_next_channel_announcements(&self, starting_point: &mut InitSyncTracker, batch_amount: u8)->(Vec<(msgs::ChannelAnnouncement, msgs::ChannelUpdate,msgs::ChannelUpdate)>){ - let mut result = Vec::new(); + fn get_next_channel_announcements(&self, starting_point: u64, batch_amount: u8) -> Vec<(msgs::ChannelAnnouncement, msgs::ChannelUpdate,msgs::ChannelUpdate)> { + let mut result = Vec::with_capacity(batch_amount as usize); let network = self.network_map.read().unwrap(); - let mut starting_for_next = if let InitSyncTracker::ChannelCounter(i) = *starting_point {i} else {0 as u64}; - let mut iter = network.channels.range((starting_for_next)..); - for _x in 0..batch_amount{ - if let Some(ref value) = iter.next(){ - if value.1.announcement_message.is_some() && value.1.one_to_two.last_update_message.is_some() && value.1.two_to_one.last_update_message.is_some(){ - let channel_announcement = value.1.announcement_message.clone().unwrap(); - let channel_update1 = value.1.one_to_two.last_update_message.clone().unwrap(); - let channel_update2 = value.1.two_to_one.last_update_message.clone().unwrap(); - result.push((channel_announcement,channel_update1, channel_update2)); + let mut iter = network.channels.range(starting_point..); + while result.len() < batch_amount as usize { + if let Some((_, ref chan)) = iter.next() { + if chan.announcement_message.is_some() && + chan.one_to_two.last_update_message.is_some() && + chan.two_to_one.last_update_message.is_some() { + result.push((chan.announcement_message.clone().unwrap(), + chan.one_to_two.last_update_message.clone().unwrap(), + chan.two_to_one.last_update_message.clone().unwrap())); + } else { + // TODO: We may end up sending un-announced channel_updates if we are sending + // initial sync data while receiving announce/updates for this channel. } - starting_for_next = *(value.0) ;//adjusting start value so we can pass the last used back + } else { + return result; } } - *starting_point = if result.len() == 0{ - InitSyncTracker::Sync(false) //sync done so disable sync required - } else { - InitSyncTracker::ChannelCounter(starting_for_next) - }; - (result) + result } - fn get_next_node_announcements(&self, starting_point: &mut InitSyncTracker, batch_amount: u8)->(Vec){ - let mut result = Vec::new(); + fn get_next_node_announcements(&self, starting_point: Option<&PublicKey>, batch_amount: u8) -> Vec { + let mut result = Vec::with_capacity(batch_amount as usize); let network = self.network_map.read().unwrap(); - let mut iter = if let InitSyncTracker::NodeCounter(i) = *starting_point {network.nodes.range((i)..)} else { - let first_item = network.nodes.iter().next(); - if let None = first_item {*starting_point = InitSyncTracker::Sync(false); return result} //for some reason we know of no nodes - network.nodes.range(*(first_item.unwrap().0)..)}; - for _x in 0..batch_amount{ - if let Some(ref value) = iter.next(){ - if value.1.announcement_message.is_some(){ - let node_announcement = value.1.announcement_message.clone().unwrap(); - result.push(node_announcement); + let mut iter = if let Some(pubkey) = starting_point { + let iter = network.nodes.range(pubkey..); + iter.next(); + iter + } else { + network.nodes.range(..) + }; + while result.len() < batch_amount as usize { + if let Some((_, ref node)) = iter.next() { + if node.announcement_message.is_some() { + result.push(node.announcement_message.clone().unwrap()); } - *starting_point = InitSyncTracker::NodeCounter(*(value.0)) ;//adjusting start value so we can pass the last used back + } else { + return result; } } - if result.len() == 0{ - *starting_point = InitSyncTracker::ChannelCounter(0) //node syncing done, move on towards channels - }; result } } @@ -954,7 +944,7 @@ mod tests { rgb: [0; 3], alias: [0; 32], addresses: Vec::new(), - announcement_message : None, + announcement_message: None, }); network.channels.insert(NetworkMap::get_key(1, zero_hash.clone()), ChannelInfo { features: GlobalFeatures::new(), @@ -977,7 +967,7 @@ mod tests { fee_proportional_millionths: 0, last_update_message: None, }, - announcement_message : None, + announcement_message: None, }); network.nodes.insert(node2.clone(), NodeInfo { channels: vec!(NetworkMap::get_key(2, zero_hash.clone()), NetworkMap::get_key(4, zero_hash.clone())), @@ -988,7 +978,7 @@ mod tests { rgb: [0; 3], alias: [0; 32], addresses: Vec::new(), - announcement_message : None, + announcement_message: None, }); network.channels.insert(NetworkMap::get_key(2, zero_hash.clone()), ChannelInfo { features: GlobalFeatures::new(), @@ -1011,7 +1001,7 @@ mod tests { fee_proportional_millionths: 0, last_update_message: None, }, - announcement_message : None, + announcement_message: None, }); network.nodes.insert(node8.clone(), NodeInfo { channels: vec!(NetworkMap::get_key(12, zero_hash.clone()), NetworkMap::get_key(13, zero_hash.clone())), @@ -1022,7 +1012,7 @@ mod tests { rgb: [0; 3], alias: [0; 32], addresses: Vec::new(), - announcement_message : None, + announcement_message: None, }); network.channels.insert(NetworkMap::get_key(12, zero_hash.clone()), ChannelInfo { features: GlobalFeatures::new(), @@ -1045,7 +1035,7 @@ mod tests { fee_proportional_millionths: 0, last_update_message: None, }, - announcement_message : None, + announcement_message: None, }); network.nodes.insert(node3.clone(), NodeInfo { channels: vec!( @@ -1062,7 +1052,7 @@ mod tests { rgb: [0; 3], alias: [0; 32], addresses: Vec::new(), - announcement_message : None, + announcement_message: None, }); network.channels.insert(NetworkMap::get_key(3, zero_hash.clone()), ChannelInfo { features: GlobalFeatures::new(), @@ -1085,7 +1075,7 @@ mod tests { fee_proportional_millionths: 0, last_update_message: None, }, - announcement_message : None, + announcement_message: None, }); network.channels.insert(NetworkMap::get_key(4, zero_hash.clone()), ChannelInfo { features: GlobalFeatures::new(), @@ -1108,7 +1098,7 @@ mod tests { fee_proportional_millionths: 0, last_update_message: None, }, - announcement_message : None, + announcement_message: None, }); network.channels.insert(NetworkMap::get_key(13, zero_hash.clone()), ChannelInfo { features: GlobalFeatures::new(), @@ -1131,7 +1121,7 @@ mod tests { fee_proportional_millionths: 0, last_update_message: None, }, - announcement_message : None, + announcement_message: None, }); network.nodes.insert(node4.clone(), NodeInfo { channels: vec!(NetworkMap::get_key(5, zero_hash.clone()), NetworkMap::get_key(11, zero_hash.clone())), @@ -1142,7 +1132,7 @@ mod tests { rgb: [0; 3], alias: [0; 32], addresses: Vec::new(), - announcement_message : None, + announcement_message: None, }); network.channels.insert(NetworkMap::get_key(5, zero_hash.clone()), ChannelInfo { features: GlobalFeatures::new(), @@ -1165,7 +1155,7 @@ mod tests { fee_proportional_millionths: 0, last_update_message: None, }, - announcement_message : None, + announcement_message: None, }); network.nodes.insert(node5.clone(), NodeInfo { channels: vec!(NetworkMap::get_key(6, zero_hash.clone()), NetworkMap::get_key(11, zero_hash.clone())), @@ -1176,7 +1166,7 @@ mod tests { rgb: [0; 3], alias: [0; 32], addresses: Vec::new(), - announcement_message : None, + announcement_message: None, }); network.channels.insert(NetworkMap::get_key(6, zero_hash.clone()), ChannelInfo { features: GlobalFeatures::new(), @@ -1199,7 +1189,7 @@ mod tests { fee_proportional_millionths: 0, last_update_message: None, }, - announcement_message : None, + announcement_message: None, }); network.channels.insert(NetworkMap::get_key(11, zero_hash.clone()), ChannelInfo { features: GlobalFeatures::new(), @@ -1222,7 +1212,7 @@ mod tests { fee_proportional_millionths: 0, last_update_message: None, }, - announcement_message : None, + announcement_message: None, }); network.nodes.insert(node6.clone(), NodeInfo { channels: vec!(NetworkMap::get_key(7, zero_hash.clone())), @@ -1233,7 +1223,7 @@ mod tests { rgb: [0; 3], alias: [0; 32], addresses: Vec::new(), - announcement_message : None, + announcement_message: None, }); network.channels.insert(NetworkMap::get_key(7, zero_hash.clone()), ChannelInfo { features: GlobalFeatures::new(), @@ -1256,7 +1246,7 @@ mod tests { fee_proportional_millionths: 0, last_update_message: None, }, - announcement_message : None, + announcement_message: None, }); } diff --git a/src/util/test_utils.rs b/src/util/test_utils.rs index 0ebe8e9a8..33fb63b5c 100644 --- a/src/util/test_utils.rs +++ b/src/util/test_utils.rs @@ -3,7 +3,7 @@ use chain::chaininterface::ConfirmationTarget; use chain::transaction::OutPoint; use ln::channelmonitor; use ln::msgs; -use ln::msgs::{HandleError, InitSyncTracker}; +use ln::msgs::{HandleError}; use util::events; use util::logger::{Logger, Level, Record}; use util::ser::{ReadableArgs, Writer}; @@ -168,10 +168,10 @@ impl msgs::RoutingMessageHandler for TestRoutingMessageHandler { Err(HandleError { err: "", action: None }) } fn handle_htlc_fail_channel_update(&self, _update: &msgs::HTLCFailChannelUpdate) {} - fn get_next_channel_announcements(&self, _starting_point: &mut InitSyncTracker, _batch_amount: u8)->(Vec<(msgs::ChannelAnnouncement, msgs::ChannelUpdate,msgs::ChannelUpdate)>){ + fn get_next_channel_announcements(&self, _starting_point: u64, _batch_amount: u8) -> Vec<(msgs::ChannelAnnouncement, msgs::ChannelUpdate,msgs::ChannelUpdate)> { Vec::new() } - fn get_next_node_announcements(&self, _starting_point: &mut InitSyncTracker, _batch_amount: u8)->(Vec){ + fn get_next_node_announcements(&self, _starting_point: Option<&PublicKey>, _batch_amount: u8) -> Vec { Vec::new() } }