@@ -14,6 +14,7 @@ use monero_serai::{block::Block, transaction::Transaction};
1414use tokio:: sync:: { broadcast, oneshot, watch} ;
1515use tokio_stream:: wrappers:: WatchStream ;
1616use tower:: { Service , ServiceExt } ;
17+ use tracing:: instrument;
1718
1819use cuprate_blockchain:: service:: BlockchainReadHandle ;
1920use cuprate_consensus:: {
@@ -22,10 +23,9 @@ use cuprate_consensus::{
2223} ;
2324use cuprate_dandelion_tower:: TxState ;
2425use cuprate_fixed_bytes:: ByteArrayVec ;
25- use cuprate_helper:: cast:: u64_to_usize;
2626use cuprate_helper:: {
2727 asynch:: rayon_spawn_async,
28- cast:: usize_to_u64,
28+ cast:: { u64_to_usize , usize_to_u64} ,
2929 map:: { combine_low_high_bits_to_u128, split_u128_into_low_high_bits} ,
3030} ;
3131use cuprate_p2p:: constants:: {
@@ -363,6 +363,7 @@ async fn new_fluffy_block<A: NetZoneAddress>(
363363}
364364
365365/// [`ProtocolRequest::NewTransactions`]
366+ #[ instrument( level = "debug" , skip_all, fields( txs = request. txs. len( ) , stem = !request. dandelionpp_fluff) ) ]
366367async fn new_transactions < A > (
367368 peer_information : PeerInformation < A > ,
368369 request : NewTransactions ,
@@ -373,16 +374,22 @@ where
373374 A : NetZoneAddress ,
374375 InternalPeerID < A > : Into < CrossNetworkInternalPeerId > ,
375376{
377+ tracing:: debug!( "handling new transactions" ) ;
378+
376379 let context = blockchain_context_service. blockchain_context ( ) ;
377380
378381 // If we are more than 2 blocks behind the peer then ignore the txs - we are probably still syncing.
379- if usize_to_u64 ( context. chain_height + 2 )
380- < peer_information
381- . core_sync_data
382- . lock ( )
383- . unwrap ( )
384- . current_height
385- {
382+ let peer_height = peer_information
383+ . core_sync_data
384+ . lock ( )
385+ . unwrap ( )
386+ . current_height ;
387+ if usize_to_u64 ( context. chain_height + 2 ) < peer_height {
388+ tracing:: debug!(
389+ our_height = context. chain_height,
390+ peer_height,
391+ "we are too far behind peer, ignoring txs."
392+ ) ;
386393 return Ok ( ProtocolResponse :: NA ) ;
387394 }
388395
0 commit comments