File tree Expand file tree Collapse file tree 1 file changed +15
-11
lines changed
consensus/src/quorum_store Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -42,21 +42,25 @@ impl BatchRequesterState {
4242 let mut rng = rand:: thread_rng ( ) ;
4343 // make sure nodes request from the different set of nodes
4444 self . next_index = rng. r#gen :: < usize > ( ) % signers. len ( ) ;
45- counters:: SENT_BATCH_REQUEST_COUNT . inc_by ( num_peers as u64 ) ;
45+ counters:: SENT_BATCH_REQUEST_COUNT . inc_by ( num_peers. min ( signers . len ( ) ) as u64 ) ;
4646 } else {
47- counters:: SENT_BATCH_REQUEST_RETRY_COUNT . inc_by ( num_peers as u64 ) ;
47+ counters:: SENT_BATCH_REQUEST_RETRY_COUNT . inc_by ( num_peers. min ( signers . len ( ) ) as u64 ) ;
4848 }
4949 if self . num_retries < self . retry_limit {
5050 self . num_retries += 1 ;
51- let ret = signers
52- . iter ( )
53- . cycle ( )
54- . skip ( self . next_index )
55- . take ( num_peers)
56- . cloned ( )
57- . collect ( ) ;
58- self . next_index = ( self . next_index + num_peers) % signers. len ( ) ;
59- Some ( ret)
51+ if signers. len ( ) <= num_peers {
52+ Some ( signers. iter ( ) . cloned ( ) . collect ( ) )
53+ } else {
54+ let ret = signers
55+ . iter ( )
56+ . cycle ( )
57+ . skip ( self . next_index )
58+ . take ( num_peers)
59+ . cloned ( )
60+ . collect ( ) ;
61+ self . next_index = ( self . next_index + num_peers) % signers. len ( ) ;
62+ Some ( ret)
63+ }
6064 } else {
6165 None
6266 }
You can’t perform that action at this time.
0 commit comments