@@ -12,7 +12,6 @@ use crate::{
1212} ;
1313use alloy_consensus:: BlockHeader ;
1414use alloy_primitives:: B256 ;
15- use rand:: seq:: SliceRandom ;
1615use reth_eth_wire:: {
1716 BlockHashNumber , Capabilities , DisconnectReason , EthNetworkPrimitives , NetworkPrimitives ,
1817 NewBlockHashes , NewBlockPayload , UnifiedStatus ,
@@ -192,21 +191,13 @@ impl<N: NetworkPrimitives> NetworkState<N> {
192191 ///
193192 /// This is supposed to be invoked after the block was validated.
194193 ///
195- /// > It then sends the block to a small fraction of connected peers (usually the square root of
196- /// > the total number of peers) using the `NewBlock` message .
194+ /// Note: Sends a `NewBlock` message to all of the connected peers. This is okay because this
195+ /// method is only used until we deprecate l2geth clients which don't support scroll-wire .
197196 ///
198197 /// See also <https://github.com/ethereum/devp2p/blob/master/caps/eth.md>
199198 pub ( crate ) fn announce_new_block ( & mut self , msg : NewBlockMessage < N :: NewBlockPayload > ) {
200- // send a `NewBlock` message to a fraction of the connected peers (square root of the total
201- // number of peers)
202- let num_propagate = ( self . active_peers . len ( ) as f64 ) . sqrt ( ) as u64 + 1 ;
203-
204199 let number = msg. block . block ( ) . header ( ) . number ( ) ;
205- let mut count = 0 ;
206-
207- // Shuffle to propagate to a random sample of peers on every block announcement
208- let mut peers: Vec < _ > = self . active_peers . iter_mut ( ) . collect ( ) ;
209- peers. shuffle ( & mut rand:: rng ( ) ) ;
200+ let peers: Vec < _ > = self . active_peers . iter_mut ( ) . collect ( ) ;
210201
211202 for ( peer_id, peer) in peers {
212203 if peer. blocks . contains ( & msg. hash ) {
@@ -215,24 +206,16 @@ impl<N: NetworkPrimitives> NetworkState<N> {
215206 }
216207
217208 // Queue a `NewBlock` message for the peer
218- if count < num_propagate {
219- self . queued_messages
220- . push_back ( StateAction :: NewBlock { peer_id : * peer_id, block : msg. clone ( ) } ) ;
221-
222- // update peer block info
223- if self . state_fetcher . update_peer_block ( peer_id, msg. hash , number) {
224- peer. best_hash = msg. hash ;
225- }
209+ self . queued_messages
210+ . push_back ( StateAction :: NewBlock { peer_id : * peer_id, block : msg. clone ( ) } ) ;
226211
227- // mark the block as seen by the peer
228- peer. blocks . insert ( msg. hash ) ;
229-
230- count += 1 ;
212+ // update peer block info
213+ if self . state_fetcher . update_peer_block ( peer_id, msg. hash , number) {
214+ peer. best_hash = msg. hash ;
231215 }
232216
233- if count >= num_propagate {
234- break
235- }
217+ // mark the block as seen by the peer
218+ peer. blocks . insert ( msg. hash ) ;
236219 }
237220 }
238221
0 commit comments