@@ -108,7 +108,7 @@ public void accept(BlockWrapper blockWrapper) {
108
108
private long importStart ;
109
109
private EthereumListener .SyncState syncDoneType = EthereumListener .SyncState .COMPLETE ;
110
110
private ScheduledExecutorService logExecutor = Executors .newSingleThreadScheduledExecutor ();
111
- private LocalDateTime lastSyncAction ;
111
+ private LocalDateTime initRegularTime ;
112
112
113
113
private AtomicInteger blocksInMem = new AtomicInteger (0 );
114
114
@@ -171,15 +171,17 @@ void initRegularSync(EthereumListener.SyncState syncDoneType) {
171
171
172
172
if (config .makeDoneByTimeout () >= 0 ) {
173
173
logger .info ("Custom long sync done timeout set to {} second(s)" , config .makeDoneByTimeout ());
174
- this .lastSyncAction = LocalDateTime .now ();
174
+ this .initRegularTime = LocalDateTime .now ();
175
175
ScheduledExecutorService shortSyncAwait = Executors .newSingleThreadScheduledExecutor ();
176
176
shortSyncAwait .scheduleAtFixedRate (() -> {
177
177
try {
178
- if (LocalDateTime .now ().minusSeconds (config .makeDoneByTimeout ()).isAfter (lastSyncAction ) &&
178
+ if (LocalDateTime .now ().minusSeconds (config .makeDoneByTimeout ()).isAfter (initRegularTime ) &&
179
179
getLastKnownBlockNumber () == blockchain .getBestBlock ().getNumber ()) {
180
180
logger .info ("Sync done triggered by timeout" );
181
181
makeSyncDone ();
182
182
shortSyncAwait .shutdown ();
183
+ } else if (syncDone ) {
184
+ shortSyncAwait .shutdown ();
183
185
}
184
186
} catch (Exception e ) {
185
187
logger .error ("Unexpected" , e );
@@ -296,9 +298,6 @@ private void produceQueue() {
296
298
if (wrapper .isNewBlock () && !syncDone ) {
297
299
makeSyncDone ();
298
300
}
299
- if (config .makeDoneByTimeout () >= 0 && !syncDone ) {
300
- this .lastSyncAction = LocalDateTime .now ();
301
- }
302
301
}
303
302
304
303
if (importResult == IMPORTED_NOT_BEST )
0 commit comments