@@ -43,6 +43,7 @@ impl TransitionFrontierSyncLedgerSnarkedState {
4343 TransitionFrontierSyncLedgerSnarkedAction :: PeersQuery => {
4444 let mut retry_addresses: Vec < _ > = state. sync_address_retry_iter ( ) . collect ( ) ;
4545 let mut addresses: Vec < _ > = state. sync_address_query_iter ( ) . collect ( ) ;
46+ let is_num_accounts_pending = matches ! ( state, Self :: NumAccountsPending { .. } ) ;
4647
4748 let ( dispatcher, global_state) = state_context. into_dispatcher_and_state ( ) ;
4849
@@ -55,24 +56,26 @@ impl TransitionFrontierSyncLedgerSnarkedState {
5556 . collect :: < Vec < _ > > ( ) ;
5657 peer_ids. sort_by ( |( _, t1) , ( _, t2) | t2. cmp ( t1) ) ;
5758
58- // If this dispatches, we can avoid even trying the following steps because we will
59- // not query address unless we have completed the Num_accounts request first.
60- if let Some ( ( peer_id , _ ) ) = peer_ids . first ( ) {
61- if dispatcher . push_if_enabled (
62- TransitionFrontierSyncLedgerSnarkedAction :: PeerQueryNumAccountsInit {
63- peer_id : * peer_id ,
64- } ,
65- global_state ,
66- meta . time ( ) ,
67- ) || dispatcher . push_if_enabled (
68- TransitionFrontierSyncLedgerSnarkedAction :: PeerQueryNumAccountsRetry {
69- peer_id : * peer_id ,
70- } ,
71- global_state ,
72- meta . time ( ) ,
73- ) {
74- return ;
59+ if is_num_accounts_pending {
60+ for ( peer_id , _ ) in peer_ids {
61+ if dispatcher . push_if_enabled (
62+ TransitionFrontierSyncLedgerSnarkedAction :: PeerQueryNumAccountsInit {
63+ peer_id ,
64+ } ,
65+ global_state ,
66+ meta . time ( ) ,
67+ ) || dispatcher . push_if_enabled (
68+ TransitionFrontierSyncLedgerSnarkedAction :: PeerQueryNumAccountsRetry {
69+ peer_id ,
70+ } ,
71+ global_state ,
72+ meta . time ( ) ,
73+ ) {
74+ return ;
75+ }
7576 }
77+ // we will not query addresses unless we have num accounts.
78+ return ;
7679 }
7780
7881 for ( peer_id, _) in peer_ids {
0 commit comments