@@ -38,7 +38,7 @@ use super::{
3838 dialog:: Dialog ,
3939 error:: NodeError ,
4040 messages:: { ClientMessage , Event , Log , SyncUpdate , Warning } ,
41- FilterSyncPolicy , LastBlockMonitor , PeerTimeoutConfig ,
41+ FilterSyncPolicy , LastBlockMonitor , PeerId , PeerTimeoutConfig ,
4242} ;
4343
4444pub ( crate ) const ADDR_V2_VERSION : u32 = 70015 ;
@@ -211,13 +211,13 @@ impl<H: HeaderStore, P: PeerStore> Node<H, P> {
211211 } ;
212212 let response = self . handle_version( peer_thread. nonce, version, best) . await ?;
213213 self . send_message( peer_thread. nonce, response) . await ;
214- self . dialog. send_dialog( format!( "[Peer {}]: version" , peer_thread. nonce) )
214+ self . dialog. send_dialog( format!( "[{}]: version" , peer_thread. nonce) )
215215 . await ;
216216 }
217217 PeerMessage :: Addr ( addresses) => self . handle_new_addrs( addresses) . await ,
218218 PeerMessage :: Headers ( headers) => {
219219 last_block. reset( ) ;
220- self . dialog. send_dialog( format!( "[Peer {}]: headers" , peer_thread. nonce) )
220+ self . dialog. send_dialog( format!( "[{}]: headers" , peer_thread. nonce) )
221221 . await ;
222222 match self . handle_headers( peer_thread. nonce, headers) . await {
223223 Some ( response) => {
@@ -227,7 +227,7 @@ impl<H: HeaderStore, P: PeerStore> Node<H, P> {
227227 }
228228 }
229229 PeerMessage :: FilterHeaders ( cf_headers) => {
230- self . dialog. send_dialog( format!( "[Peer {}]: filter headers" , peer_thread. nonce) ) . await ;
230+ self . dialog. send_dialog( format!( "[{}]: filter headers" , peer_thread. nonce) ) . await ;
231231 match self . handle_cf_headers( peer_thread. nonce, cf_headers) . await {
232232 Some ( response) => {
233233 self . broadcast( response) . await ;
@@ -250,7 +250,7 @@ impl<H: HeaderStore, P: PeerStore> Node<H, P> {
250250 None => continue ,
251251 } ,
252252 PeerMessage :: NewBlocks ( blocks) => {
253- self . dialog. send_dialog( format!( "[Peer {}]: inv" , peer_thread. nonce) )
253+ self . dialog. send_dialog( format!( "[{}]: inv" , peer_thread. nonce) )
254254 . await ;
255255 match self . handle_inventory_blocks( peer_thread. nonce, blocks) . await {
256256 Some ( response) => {
@@ -340,7 +340,7 @@ impl<H: HeaderStore, P: PeerStore> Node<H, P> {
340340 }
341341
342342 // Send a message to a specified peer
343- async fn send_message ( & self , nonce : u32 , message : MainThreadMessage ) {
343+ async fn send_message ( & self , nonce : PeerId , message : MainThreadMessage ) {
344344 let mut peer_map = self . peer_map . lock ( ) . await ;
345345 peer_map. send_message ( nonce, message) . await ;
346346 }
@@ -524,7 +524,7 @@ impl<H: HeaderStore, P: PeerStore> Node<H, P> {
524524 // We accepted a handshake with a peer but we may disconnect if they do not support CBF
525525 async fn handle_version (
526526 & self ,
527- nonce : u32 ,
527+ nonce : PeerId ,
528528 version_message : VersionMessage ,
529529 best_height : u32 ,
530530 ) -> Result < MainThreadMessage , NodeError < H :: Error , P :: Error > > {
@@ -590,7 +590,7 @@ impl<H: HeaderStore, P: PeerStore> Node<H, P> {
590590 // We always send headers to our peers, so our next message depends on our state
591591 async fn handle_headers (
592592 & self ,
593- peer_id : u32 ,
593+ peer_id : PeerId ,
594594 headers : Vec < Header > ,
595595 ) -> Option < MainThreadMessage > {
596596 let mut chain = self . chain . lock ( ) . await ;
@@ -624,11 +624,11 @@ impl<H: HeaderStore, P: PeerStore> Node<H, P> {
624624 // Compact filter headers may result in a number of outcomes, including the need to audit filters.
625625 async fn handle_cf_headers (
626626 & self ,
627- peer_id : u32 ,
627+ peer_id : PeerId ,
628628 cf_headers : CFHeaders ,
629629 ) -> Option < MainThreadMessage > {
630630 let mut chain = self . chain . lock ( ) . await ;
631- match chain. sync_cf_headers ( peer_id, cf_headers) . await {
631+ match chain. sync_cf_headers ( peer_id. 0 , cf_headers) . await {
632632 Ok ( potential_message) => match potential_message {
633633 AppendAttempt :: AddedToQueue => None ,
634634 AppendAttempt :: Extended => self . next_stateful_message ( chain. deref_mut ( ) ) . await ,
@@ -652,7 +652,7 @@ impl<H: HeaderStore, P: PeerStore> Node<H, P> {
652652 }
653653
654654 // Handle a new compact block filter
655- async fn handle_filter ( & self , peer_id : u32 , filter : CFilter ) -> Option < MainThreadMessage > {
655+ async fn handle_filter ( & self , peer_id : PeerId , filter : CFilter ) -> Option < MainThreadMessage > {
656656 let mut chain = self . chain . lock ( ) . await ;
657657 match chain. sync_filter ( filter) . await {
658658 Ok ( potential_message) => potential_message. map ( MainThreadMessage :: GetFilters ) ,
@@ -673,7 +673,7 @@ impl<H: HeaderStore, P: PeerStore> Node<H, P> {
673673 }
674674
675675 // Scan a block for transactions.
676- async fn handle_block ( & self , peer_id : u32 , block : Block ) -> Option < MainThreadMessage > {
676+ async fn handle_block ( & self , peer_id : PeerId , block : Block ) -> Option < MainThreadMessage > {
677677 let mut chain = self . chain . lock ( ) . await ;
678678 if let Err ( e) = chain. check_send_block ( block) . await {
679679 self . dialog . send_warning ( Warning :: UnexpectedSyncError {
@@ -713,7 +713,7 @@ impl<H: HeaderStore, P: PeerStore> Node<H, P> {
713713 // If new inventory came in, we need to download the headers and update the node state
714714 async fn handle_inventory_blocks (
715715 & self ,
716- nonce : u32 ,
716+ nonce : PeerId ,
717717 blocks : Vec < BlockHash > ,
718718 ) -> Option < MainThreadMessage > {
719719 let mut state = self . state . write ( ) . await ;
0 commit comments