@@ -27,7 +27,7 @@ use crate::ln::peer_channel_encryptor::{PeerChannelEncryptor,NextNoiseStep};
2727use crate :: ln:: wire;
2828use crate :: ln:: wire:: Encode ;
2929use crate :: onion_message:: { CustomOnionMessageContents , CustomOnionMessageHandler , SimpleArcOnionMessenger , SimpleRefOnionMessenger } ;
30- use crate :: routing:: gossip:: { NetworkGraph , P2PGossipSync } ;
30+ use crate :: routing:: gossip:: { NetworkGraph , P2PGossipSync , NodeId } ;
3131use crate :: util:: atomic_counter:: AtomicCounter ;
3232use crate :: util:: events:: { MessageSendEvent , MessageSendEventsProvider , OnionMessageProvider } ;
3333use crate :: util:: logger:: Logger ;
@@ -71,7 +71,7 @@ impl RoutingMessageHandler for IgnoringMessageHandler {
7171 fn handle_channel_update ( & self , _msg : & msgs:: ChannelUpdate ) -> Result < bool , LightningError > { Ok ( false ) }
7272 fn get_next_channel_announcement ( & self , _starting_point : u64 ) ->
7373 Option < ( msgs:: ChannelAnnouncement , Option < msgs:: ChannelUpdate > , Option < msgs:: ChannelUpdate > ) > { None }
74- fn get_next_node_announcement ( & self , _starting_point : Option < & PublicKey > ) -> Option < msgs:: NodeAnnouncement > { None }
74+ fn get_next_node_announcement ( & self , _starting_point : Option < & NodeId > ) -> Option < msgs:: NodeAnnouncement > { None }
7575 fn peer_connected ( & self , _their_node_id : & PublicKey , _init : & msgs:: Init ) -> Result < ( ) , ( ) > { Ok ( ( ) ) }
7676 fn handle_reply_channel_range ( & self , _their_node_id : & PublicKey , _msg : msgs:: ReplyChannelRange ) -> Result < ( ) , LightningError > { Ok ( ( ) ) }
7777 fn handle_reply_short_channel_ids_end ( & self , _their_node_id : & PublicKey , _msg : msgs:: ReplyShortChannelIdsEnd ) -> Result < ( ) , LightningError > { Ok ( ( ) ) }
@@ -345,7 +345,7 @@ impl error::Error for PeerHandleError {
345345enum InitSyncTracker {
346346 NoSyncRequested ,
347347 ChannelsSyncing ( u64 ) ,
348- NodesSyncing ( PublicKey ) ,
348+ NodesSyncing ( NodeId ) ,
349349}
350350
351351/// The ratio between buffer sizes at which we stop sending initial sync messages vs when we stop
@@ -434,15 +434,15 @@ impl Peer {
434434 }
435435
436436 /// Similar to the above, but for node announcements indexed by node_id.
437- fn should_forward_node_announcement ( & self , node_id : PublicKey ) -> bool {
437+ fn should_forward_node_announcement ( & self , node_id : NodeId ) -> bool {
438438 if self . their_features . as_ref ( ) . unwrap ( ) . supports_gossip_queries ( ) &&
439439 !self . sent_gossip_timestamp_filter {
440440 return false ;
441441 }
442442 match self . sync_status {
443443 InitSyncTracker :: NoSyncRequested => true ,
444444 InitSyncTracker :: ChannelsSyncing ( _) => false ,
445- InitSyncTracker :: NodesSyncing ( pk ) => pk < node_id,
445+ InitSyncTracker :: NodesSyncing ( sync_node_id ) => sync_node_id . as_slice ( ) < node_id. as_slice ( ) ,
446446 }
447447 }
448448
@@ -889,8 +889,8 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
889889 }
890890 } ,
891891 InitSyncTracker :: ChannelsSyncing ( _) => unreachable ! ( ) ,
892- InitSyncTracker :: NodesSyncing ( key ) => {
893- if let Some ( msg) = self . message_handler . route_handler . get_next_node_announcement ( Some ( & key ) ) {
892+ InitSyncTracker :: NodesSyncing ( sync_node_id ) => {
893+ if let Some ( msg) = self . message_handler . route_handler . get_next_node_announcement ( Some ( & sync_node_id ) ) {
894894 self . enqueue_message ( peer, & msg) ;
895895 peer. sync_status = InitSyncTracker :: NodesSyncing ( msg. contents . node_id ) ;
896896 } else {
@@ -1467,9 +1467,11 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
14671467 log_gossip ! ( self . logger, "Skipping broadcast message to {:?} as its outbound buffer is full" , peer. their_node_id) ;
14681468 continue ;
14691469 }
1470- if peer. their_node_id . as_ref ( ) == Some ( & msg. contents . node_id_1 ) ||
1471- peer. their_node_id . as_ref ( ) == Some ( & msg. contents . node_id_2 ) {
1472- continue ;
1470+ if let Some ( their_node_id) = peer. their_node_id {
1471+ let their_node_id = NodeId :: from_pubkey ( & their_node_id) ;
1472+ if their_node_id == msg. contents . node_id_1 || their_node_id == msg. contents . node_id_2 {
1473+ continue ;
1474+ }
14731475 }
14741476 if except_node. is_some ( ) && peer. their_node_id . as_ref ( ) == except_node {
14751477 continue ;
@@ -1491,8 +1493,10 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
14911493 log_gossip ! ( self . logger, "Skipping broadcast message to {:?} as its outbound buffer is full" , peer. their_node_id) ;
14921494 continue ;
14931495 }
1494- if peer. their_node_id . as_ref ( ) == Some ( & msg. contents . node_id ) {
1495- continue ;
1496+ if let Some ( their_node_id) = peer. their_node_id {
1497+ if NodeId :: from_pubkey ( & their_node_id) == msg. contents . node_id {
1498+ continue ;
1499+ }
14961500 }
14971501 if except_node. is_some ( ) && peer. their_node_id . as_ref ( ) == except_node {
14981502 continue ;
@@ -2021,7 +2025,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
20212025 let announcement = msgs:: UnsignedNodeAnnouncement {
20222026 features,
20232027 timestamp : self . last_node_announcement_serial . fetch_add ( 1 , Ordering :: AcqRel ) ,
2024- node_id : self . node_signer . get_node_id ( Recipient :: Node ) . unwrap ( ) ,
2028+ node_id : NodeId :: from_pubkey ( & self . node_signer . get_node_id ( Recipient :: Node ) . unwrap ( ) ) ,
20252029 rgb, alias, addresses,
20262030 excess_address_data : Vec :: new ( ) ,
20272031 excess_data : Vec :: new ( ) ,
0 commit comments