@@ -112,17 +112,31 @@ where
112112 Ok ( unconfirmed_txs) => {
113113 // Double-check the tip hash. If it changed, a reorg happened since
114114 // we started syncing and we need to restart last-minute.
115- if self . check_update_tip ( & mut tip_header, & mut tip_height) ?
116- {
117- log_debug ! ( self . logger,
118- "Encountered inconsistency during transaction sync, restarting." ) ;
119- sync_state. pending_sync = true ;
120- continue ;
115+ match self . check_update_tip ( & mut tip_header, & mut tip_height) {
116+ Ok ( false ) => {
117+ num_unconfirmed += unconfirmed_txs. len ( ) ;
118+ sync_state. sync_unconfirmed_transactions (
119+ & confirmables,
120+ unconfirmed_txs
121+ ) ;
122+ }
123+ Ok ( true ) => {
124+ log_debug ! ( self . logger,
125+ "Encountered inconsistency during transaction sync, restarting." ) ;
126+ sync_state. pending_sync = true ;
127+ continue ;
128+ }
129+ Err ( err) => {
130+ // (Semi-)permanent failure, retry later.
131+ log_error ! ( self . logger,
132+ "Failed during transaction sync, aborting. Synced so far: {} confirmed, {} unconfirmed." ,
133+ num_confirmed,
134+ num_unconfirmed
135+ ) ;
136+ sync_state. pending_sync = true ;
137+ return Err ( TxSyncError :: from ( err) ) ;
138+ }
121139 }
122-
123- num_unconfirmed += unconfirmed_txs. len ( ) ;
124- sync_state. sync_unconfirmed_transactions ( & confirmables,
125- unconfirmed_txs) ;
126140 } ,
127141 Err ( err) => {
128142 // (Semi-)permanent failure, retry later.
@@ -146,19 +160,31 @@ where
146160 Ok ( confirmed_txs) => {
147161 // Double-check the tip hash. If it changed, a reorg happened since
148162 // we started syncing and we need to restart last-minute.
149- if self . check_update_tip ( & mut tip_header, & mut tip_height) ?
150- {
151- log_debug ! ( self . logger,
152- "Encountered inconsistency during transaction sync, restarting." ) ;
153- sync_state. pending_sync = true ;
154- continue ;
163+ match self . check_update_tip ( & mut tip_header, & mut tip_height) {
164+ Ok ( false ) => {
165+ num_confirmed += confirmed_txs. len ( ) ;
166+ sync_state. sync_confirmed_transactions (
167+ & confirmables,
168+ confirmed_txs
169+ ) ;
170+ }
171+ Ok ( true ) => {
172+ log_debug ! ( self . logger,
173+ "Encountered inconsistency during transaction sync, restarting." ) ;
174+ sync_state. pending_sync = true ;
175+ continue ;
176+ }
177+ Err ( err) => {
178+ // (Semi-)permanent failure, retry later.
179+ log_error ! ( self . logger,
180+ "Failed during transaction sync, aborting. Synced so far: {} confirmed, {} unconfirmed." ,
181+ num_confirmed,
182+ num_unconfirmed
183+ ) ;
184+ sync_state. pending_sync = true ;
185+ return Err ( TxSyncError :: from ( err) ) ;
186+ }
155187 }
156-
157- num_confirmed += confirmed_txs. len ( ) ;
158- sync_state. sync_confirmed_transactions (
159- & confirmables,
160- confirmed_txs,
161- ) ;
162188 }
163189 Err ( InternalError :: Inconsistency ) => {
164190 // Immediately restart syncing when we encounter any inconsistencies.
0 commit comments