@@ -114,16 +114,32 @@ where
114114 Ok ( unconfirmed_txs) => {
115115 // Double-check the tip hash. If it changed, a reorg happened since
116116 // we started syncing and we need to restart last-minute.
117- let check_tip_hash = maybe_await ! ( self . client. get_tip_hash( ) ) ?;
118- if check_tip_hash != tip_hash {
119- tip_hash = check_tip_hash;
120-
121- log_debug ! ( self . logger, "Encountered inconsistency during transaction sync, restarting." ) ;
122- sync_state. pending_sync = true ;
123- continue ;
117+ match maybe_await ! ( self . client. get_tip_hash( ) ) {
118+ Ok ( check_tip_hash) => {
119+ if check_tip_hash != tip_hash {
120+ tip_hash = check_tip_hash;
121+
122+ log_debug ! ( self . logger, "Encountered inconsistency during transaction sync, restarting." ) ;
123+ sync_state. pending_sync = true ;
124+ continue ;
125+ }
126+ num_unconfirmed += unconfirmed_txs. len ( ) ;
127+ sync_state. sync_unconfirmed_transactions (
128+ & confirmables,
129+ unconfirmed_txs
130+ ) ;
131+ }
132+ Err ( err) => {
133+ // (Semi-)permanent failure, retry later.
134+ log_error ! ( self . logger,
135+ "Failed during transaction sync, aborting. Synced so far: {} confirmed, {} unconfirmed." ,
136+ num_confirmed,
137+ num_unconfirmed
138+ ) ;
139+ sync_state. pending_sync = true ;
140+ return Err ( TxSyncError :: from ( err) ) ;
141+ }
124142 }
125- num_unconfirmed += unconfirmed_txs. len ( ) ;
126- sync_state. sync_unconfirmed_transactions ( & confirmables, unconfirmed_txs) ;
127143 } ,
128144 Err ( err) => {
129145 // (Semi-)permanent failure, retry later.
@@ -162,17 +178,33 @@ where
162178 Ok ( confirmed_txs) => {
163179 // Double-check the tip hash. If it changed, a reorg happened since
164180 // we started syncing and we need to restart last-minute.
165- let check_tip_hash = maybe_await ! ( self . client. get_tip_hash( ) ) ?;
166- if check_tip_hash != tip_hash {
167- tip_hash = check_tip_hash;
168- continue ;
181+ match maybe_await ! ( self . client. get_tip_hash( ) ) {
182+ Ok ( check_tip_hash) => {
183+ if check_tip_hash != tip_hash {
184+ tip_hash = check_tip_hash;
185+
186+ log_debug ! ( self . logger,
187+ "Encountered inconsistency during transaction sync, restarting." ) ;
188+ sync_state. pending_sync = true ;
189+ continue ;
190+ }
191+ num_confirmed += confirmed_txs. len ( ) ;
192+ sync_state. sync_confirmed_transactions (
193+ & confirmables,
194+ confirmed_txs
195+ ) ;
196+ }
197+ Err ( err) => {
198+ // (Semi-)permanent failure, retry later.
199+ log_error ! ( self . logger,
200+ "Failed during transaction sync, aborting. Synced so far: {} confirmed, {} unconfirmed." ,
201+ num_confirmed,
202+ num_unconfirmed
203+ ) ;
204+ sync_state. pending_sync = true ;
205+ return Err ( TxSyncError :: from ( err) ) ;
206+ }
169207 }
170-
171- num_confirmed += confirmed_txs. len ( ) ;
172- sync_state. sync_confirmed_transactions (
173- & confirmables,
174- confirmed_txs,
175- ) ;
176208 }
177209 Err ( InternalError :: Inconsistency ) => {
178210 // Immediately restart syncing when we encounter any inconsistencies.
0 commit comments