@@ -91,19 +91,23 @@ impl SyncPropagator {
91
91
sent
92
92
}
93
93
94
- /// propagate new known pool hashes to all peers
95
- pub fn propagate_new_pooled_tx_hashes ( sync : & mut ChainSync , io : & mut dyn SyncIo ) -> usize {
96
- /// Recommended limit from the spec.
97
- const LIMIT : usize = 4096 ;
94
+ /// propagates new transactions to all peers
95
+ pub fn propagate_new_transactions < F : FnMut ( ) -> bool > ( sync : & mut ChainSync , io : & mut dyn SyncIo , mut should_continue : F ) -> usize {
96
+ const NEW_POOLED_HASHES_LIMIT : usize = 4096 ;
97
+
98
+ // Early out if nobody to send to.
99
+ if sync. peers . is_empty ( ) {
100
+ return 0 ;
101
+ }
98
102
103
+ // propagate just hashes to newer peers
99
104
trace ! ( target: "sync" , "Sending NewPooledTransactionsHashes to {:?}" , sync. peers. keys( ) ) ;
100
- let mut affected_peers = 0 ;
101
105
for ( peer_id, peer) in & mut sync. peers {
102
106
let mut affected = false ;
103
107
let mut packet = RlpStream :: new ( ) ;
104
108
packet. begin_unbounded_list ( ) ;
105
109
if let Some ( s) = & mut peer. unsent_pooled_hashes {
106
- for item in s. drain ( ) . take ( LIMIT ) {
110
+ for item in s. drain ( ) . take ( NEW_POOLED_HASHES_LIMIT ) {
107
111
affected = true ;
108
112
packet. append ( & item) ;
109
113
}
@@ -113,23 +117,9 @@ impl SyncPropagator {
113
117
packet. finalize_unbounded_list ( ) ;
114
118
115
119
SyncPropagator :: send_packet ( io, * peer_id, NewPooledTransactionHashesPacket , packet. out ( ) ) ;
116
- affected_peers += 1 ;
117
120
}
118
121
}
119
122
120
- affected_peers
121
- }
122
-
123
- /// propagates new transactions to all peers
124
- pub fn propagate_new_transactions < F : FnMut ( ) -> bool > ( sync : & mut ChainSync , io : & mut dyn SyncIo , mut should_continue : F ) -> usize {
125
- // Early out if nobody to send to.
126
- if sync. peers . is_empty ( ) {
127
- return 0 ;
128
- }
129
-
130
- // propagate just hashes to newer peers
131
- SyncPropagator :: propagate_new_pooled_tx_hashes ( sync, io) ;
132
-
133
123
let transactions = io. chain ( ) . transactions_to_propagate ( ) ;
134
124
if transactions. is_empty ( ) {
135
125
return 0 ;
0 commit comments