@@ -192,21 +192,13 @@ impl<N: NetworkPrimitives> NetworkState<N> {
192192 ///
193193 /// This is supposed to be invoked after the block was validated.
194194 ///
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 .
195+ /// Note: Sends a `NewBlock` message to all of the connected peers. This is okay because this
196+ /// method is only used until we deprecate l2geth clients which don't support scroll-wire .
197197 ///
198198 /// See also <https://github.com/ethereum/devp2p/blob/master/caps/eth.md>
199199 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-
204200 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 ( ) ) ;
201+ let peers: Vec < _ > = self . active_peers . iter_mut ( ) . collect ( ) ;
210202
211203 for ( peer_id, peer) in peers {
212204 if peer. blocks . contains ( & msg. hash ) {
@@ -215,24 +207,16 @@ impl<N: NetworkPrimitives> NetworkState<N> {
215207 }
216208
217209 // 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- }
210+ self . queued_messages
211+ . push_back ( StateAction :: NewBlock { peer_id : * peer_id, block : msg. clone ( ) } ) ;
226212
227- // mark the block as seen by the peer
228- peer. blocks . insert ( msg. hash ) ;
229-
230- count += 1 ;
213+ // update peer block info
214+ if self . state_fetcher . update_peer_block ( peer_id, msg. hash , number) {
215+ peer. best_hash = msg. hash ;
231216 }
232217
233- if count >= num_propagate {
234- break
235- }
218+ // mark the block as seen by the peer
219+ peer. blocks . insert ( msg. hash ) ;
236220 }
237221 }
238222
0 commit comments