Skip to content

Commit

Permalink
f rename methods
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueMatt committed Aug 10, 2022
1 parent 3ee065b commit 92b767b
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions lightning-net-tokio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,8 @@ mod tests {
fn handle_node_announcement(&self, _msg: &NodeAnnouncement) -> Result<bool, LightningError> { Ok(false) }
fn handle_channel_announcement(&self, _msg: &ChannelAnnouncement) -> Result<bool, LightningError> { Ok(false) }
fn handle_channel_update(&self, _msg: &ChannelUpdate) -> Result<bool, LightningError> { Ok(false) }
fn get_next_channel_announcements(&self, _starting_point: u64) -> Option<(ChannelAnnouncement, Option<ChannelUpdate>, Option<ChannelUpdate>)> { None }
fn get_next_node_announcements(&self, _starting_point: Option<&PublicKey>) -> Option<NodeAnnouncement> { None }
fn get_next_channel_announcement(&self, _starting_point: u64) -> Option<(ChannelAnnouncement, Option<ChannelUpdate>, Option<ChannelUpdate>)> { None }
fn get_next_node_announcement(&self, _starting_point: Option<&PublicKey>) -> Option<NodeAnnouncement> { None }
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(()) }
Expand Down
8 changes: 4 additions & 4 deletions lightning/src/ln/functional_test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ impl<'a, 'b, 'c> Drop for Node<'a, 'b, 'c> {
);
let mut chan_progress = 0;
loop {
let orig_announcements = self.gossip_sync.get_next_channel_announcements(chan_progress);
let deserialized_announcements = gossip_sync.get_next_channel_announcements(chan_progress);
let orig_announcements = self.gossip_sync.get_next_channel_announcement(chan_progress);
let deserialized_announcements = gossip_sync.get_next_channel_announcement(chan_progress);
assert!(orig_announcements == deserialized_announcements);
chan_progress = match orig_announcements {
Some(announcement) => announcement.0.contents.short_channel_id + 1,
Expand All @@ -328,8 +328,8 @@ impl<'a, 'b, 'c> Drop for Node<'a, 'b, 'c> {
}
let mut node_progress = None;
loop {
let orig_announcements = self.gossip_sync.get_next_node_announcements(node_progress.as_ref());
let deserialized_announcements = gossip_sync.get_next_node_announcements(node_progress.as_ref());
let orig_announcements = self.gossip_sync.get_next_node_announcement(node_progress.as_ref());
let deserialized_announcements = gossip_sync.get_next_node_announcement(node_progress.as_ref());
assert!(orig_announcements == deserialized_announcements);
node_progress = match orig_announcements {
Some(announcement) => Some(announcement.contents.node_id),
Expand Down
4 changes: 2 additions & 2 deletions lightning/src/ln/msgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -918,12 +918,12 @@ pub trait RoutingMessageHandler : MessageSendEventsProvider {
/// Gets 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 announcements
/// for a single channel.
fn get_next_channel_announcements(&self, starting_point: u64) -> Option<(ChannelAnnouncement, Option<ChannelUpdate>, Option<ChannelUpdate>)>;
fn get_next_channel_announcement(&self, starting_point: u64) -> Option<(ChannelAnnouncement, Option<ChannelUpdate>, Option<ChannelUpdate>)>;
/// Gets a node announcement required to dump our routing table to a remote node, starting at
/// the node *after* the provided publickey and including up to one announcement immediately
/// higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
/// If None is provided for starting_point, we start at the first node.
fn get_next_node_announcements(&self, starting_point: Option<&PublicKey>) -> Option<NodeAnnouncement>;
fn get_next_node_announcement(&self, starting_point: Option<&PublicKey>) -> Option<NodeAnnouncement>;
/// Called when a connection is established with a peer. This can be used to
/// perform routing table synchronization using a strategy defined by the
/// implementor.
Expand Down
10 changes: 5 additions & 5 deletions lightning/src/ln/peer_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ impl RoutingMessageHandler for IgnoringMessageHandler {
fn handle_node_announcement(&self, _msg: &msgs::NodeAnnouncement) -> Result<bool, LightningError> { Ok(false) }
fn handle_channel_announcement(&self, _msg: &msgs::ChannelAnnouncement) -> Result<bool, LightningError> { Ok(false) }
fn handle_channel_update(&self, _msg: &msgs::ChannelUpdate) -> Result<bool, LightningError> { Ok(false) }
fn get_next_channel_announcements(&self, _starting_point: u64) ->
fn get_next_channel_announcement(&self, _starting_point: u64) ->
Option<(msgs::ChannelAnnouncement, Option<msgs::ChannelUpdate>, Option<msgs::ChannelUpdate>)> { None }
fn get_next_node_announcements(&self, _starting_point: Option<&PublicKey>) -> Option<msgs::NodeAnnouncement> { None }
fn get_next_node_announcement(&self, _starting_point: Option<&PublicKey>) -> Option<msgs::NodeAnnouncement> { None }
fn peer_connected(&self, _their_node_id: &PublicKey, _init: &msgs::Init) {}
fn handle_reply_channel_range(&self, _their_node_id: &PublicKey, _msg: msgs::ReplyChannelRange) -> Result<(), LightningError> { Ok(()) }
fn handle_reply_short_channel_ids_end(&self, _their_node_id: &PublicKey, _msg: msgs::ReplyShortChannelIdsEnd) -> Result<(), LightningError> { Ok(()) }
Expand Down Expand Up @@ -742,7 +742,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref, CMH: Deref> P
InitSyncTracker::NoSyncRequested => {},
InitSyncTracker::ChannelsSyncing(c) if c < 0xffff_ffff_ffff_ffff => {
if let Some((announce, update_a_option, update_b_option)) =
self.message_handler.route_handler.get_next_channel_announcements(c)
self.message_handler.route_handler.get_next_channel_announcement(c)
{
self.enqueue_message(peer, &announce);
if let Some(update_a) = update_a_option {
Expand All @@ -757,7 +757,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref, CMH: Deref> P
}
},
InitSyncTracker::ChannelsSyncing(c) if c == 0xffff_ffff_ffff_ffff => {
if let Some(msg) = self.message_handler.route_handler.get_next_node_announcements(None) {
if let Some(msg) = self.message_handler.route_handler.get_next_node_announcement(None) {
self.enqueue_message(peer, &msg);
peer.sync_status = InitSyncTracker::NodesSyncing(msg.contents.node_id);
} else {
Expand All @@ -766,7 +766,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref, CMH: Deref> P
},
InitSyncTracker::ChannelsSyncing(_) => unreachable!(),
InitSyncTracker::NodesSyncing(key) => {
if let Some(msg) = self.message_handler.route_handler.get_next_node_announcements(Some(&key)) {
if let Some(msg) = self.message_handler.route_handler.get_next_node_announcement(Some(&key)) {
self.enqueue_message(peer, &msg);
peer.sync_status = InitSyncTracker::NodesSyncing(msg.contents.node_id);
} else {
Expand Down
24 changes: 12 additions & 12 deletions lightning/src/routing/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ where C::Target: chain::Access, L::Target: Logger
Ok(msg.contents.excess_data.len() <= MAX_EXCESS_BYTES_FOR_RELAY)
}

fn get_next_channel_announcements(&self, starting_point: u64) -> Option<(ChannelAnnouncement, Option<ChannelUpdate>, Option<ChannelUpdate>)> {
fn get_next_channel_announcement(&self, starting_point: u64) -> Option<(ChannelAnnouncement, Option<ChannelUpdate>, Option<ChannelUpdate>)> {
let channels = self.network_graph.channels.read().unwrap();
let mut iter = channels.range(starting_point..);
loop {
Expand All @@ -344,7 +344,7 @@ where C::Target: chain::Access, L::Target: Logger
}
}

fn get_next_node_announcements(&self, starting_point: Option<&PublicKey>) -> Option<NodeAnnouncement> {
fn get_next_node_announcement(&self, starting_point: Option<&PublicKey>) -> Option<NodeAnnouncement> {
let nodes = self.network_graph.nodes.read().unwrap();
let mut iter = if let Some(pubkey) = starting_point {
let mut iter = nodes.range(NodeId::from_pubkey(pubkey)..);
Expand Down Expand Up @@ -2408,7 +2408,7 @@ mod tests {
let node_2_privkey = &SecretKey::from_slice(&[41; 32]).unwrap();

// Channels were not announced yet.
let channels_with_announcements = gossip_sync.get_next_channel_announcements(0);
let channels_with_announcements = gossip_sync.get_next_channel_announcement(0);
assert!(channels_with_announcements.is_none());

let short_channel_id;
Expand All @@ -2423,7 +2423,7 @@ mod tests {
}

// Contains initial channel announcement now.
let channels_with_announcements = gossip_sync.get_next_channel_announcements(short_channel_id);
let channels_with_announcements = gossip_sync.get_next_channel_announcement(short_channel_id);
if let Some(channel_announcements) = channels_with_announcements {
let (_, ref update_1, ref update_2) = channel_announcements;
assert_eq!(update_1, &None);
Expand All @@ -2444,7 +2444,7 @@ mod tests {
}

// Now contains an initial announcement and an update.
let channels_with_announcements = gossip_sync.get_next_channel_announcements(short_channel_id);
let channels_with_announcements = gossip_sync.get_next_channel_announcement(short_channel_id);
if let Some(channel_announcements) = channels_with_announcements {
let (_, ref update_1, ref update_2) = channel_announcements;
assert_ne!(update_1, &None);
Expand All @@ -2466,7 +2466,7 @@ mod tests {
}

// Test that announcements with excess data won't be returned
let channels_with_announcements = gossip_sync.get_next_channel_announcements(short_channel_id);
let channels_with_announcements = gossip_sync.get_next_channel_announcement(short_channel_id);
if let Some(channel_announcements) = channels_with_announcements {
let (_, ref update_1, ref update_2) = channel_announcements;
assert_eq!(update_1, &None);
Expand All @@ -2476,7 +2476,7 @@ mod tests {
}

// Further starting point have no channels after it
let channels_with_announcements = gossip_sync.get_next_channel_announcements(short_channel_id + 1000);
let channels_with_announcements = gossip_sync.get_next_channel_announcement(short_channel_id + 1000);
assert!(channels_with_announcements.is_none());
}

Expand All @@ -2489,7 +2489,7 @@ mod tests {
let node_id_1 = PublicKey::from_secret_key(&secp_ctx, node_1_privkey);

// No nodes yet.
let next_announcements = gossip_sync.get_next_node_announcements(None);
let next_announcements = gossip_sync.get_next_node_announcement(None);
assert!(next_announcements.is_none());

{
Expand All @@ -2502,7 +2502,7 @@ mod tests {
}

// Nodes were never announced
let next_announcements = gossip_sync.get_next_node_announcements(None);
let next_announcements = gossip_sync.get_next_node_announcement(None);
assert!(next_announcements.is_none());

{
Expand All @@ -2519,11 +2519,11 @@ mod tests {
};
}

let next_announcements = gossip_sync.get_next_node_announcements(None);
let next_announcements = gossip_sync.get_next_node_announcement(None);
assert!(next_announcements.is_some());

// Skip the first node.
let next_announcements = gossip_sync.get_next_node_announcements(Some(&node_id_1));
let next_announcements = gossip_sync.get_next_node_announcement(Some(&node_id_1));
assert!(next_announcements.is_some());

{
Expand All @@ -2538,7 +2538,7 @@ mod tests {
};
}

let next_announcements = gossip_sync.get_next_node_announcements(Some(&node_id_1));
let next_announcements = gossip_sync.get_next_node_announcement(Some(&node_id_1));
assert!(next_announcements.is_none());
}

Expand Down
4 changes: 2 additions & 2 deletions lightning/src/util/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,15 +445,15 @@ impl msgs::RoutingMessageHandler for TestRoutingMessageHandler {
self.chan_upds_recvd.fetch_add(1, Ordering::AcqRel);
Err(msgs::LightningError { err: "".to_owned(), action: msgs::ErrorAction::IgnoreError })
}
fn get_next_channel_announcements(&self, starting_point: u64) -> Option<(msgs::ChannelAnnouncement, Option<msgs::ChannelUpdate>, Option<msgs::ChannelUpdate>)> {
fn get_next_channel_announcement(&self, starting_point: u64) -> Option<(msgs::ChannelAnnouncement, Option<msgs::ChannelUpdate>, Option<msgs::ChannelUpdate>)> {
let chan_upd_1 = get_dummy_channel_update(starting_point);
let chan_upd_2 = get_dummy_channel_update(starting_point);
let chan_ann = get_dummy_channel_announcement(starting_point);

Some((chan_ann, Some(chan_upd_1), Some(chan_upd_2)))
}

fn get_next_node_announcements(&self, _starting_point: Option<&PublicKey>) -> Option<msgs::NodeAnnouncement> {
fn get_next_node_announcement(&self, _starting_point: Option<&PublicKey>) -> Option<msgs::NodeAnnouncement> {
None
}

Expand Down

0 comments on commit 92b767b

Please sign in to comment.