forked from Qortal/qortal
Break out of incoming transactions processing loop if we need to sync.
This commit is contained in:
parent
133943cd4e
commit
b6d633ab24
@ -856,6 +856,11 @@ public class Controller extends Thread {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Synchronizer.getInstance().isSyncRequestPending()) {
|
||||
LOGGER.debug("Breaking out of transaction processing loop with {} remaining, because a sync request is pending", this.incomingTransactions.size());
|
||||
return;
|
||||
}
|
||||
|
||||
TransactionData transactionData = (TransactionData) iterator.next();
|
||||
Transaction transaction = Transaction.fromData(repository, transactionData);
|
||||
|
||||
|
@ -82,6 +82,7 @@ public class Synchronizer extends Thread {
|
||||
private volatile int syncPercent = 0;
|
||||
|
||||
private static volatile boolean requestSync = false;
|
||||
private boolean syncRequestPending = false;
|
||||
|
||||
// Keep track of invalid blocks so that we don't keep trying to sync them
|
||||
private Map<String, Long> invalidBlockSignatures = Collections.synchronizedMap(new HashMap<>());
|
||||
@ -123,6 +124,8 @@ public class Synchronizer extends Thread {
|
||||
// Something went wrong, so try again next time
|
||||
requestSync = true;
|
||||
}
|
||||
// Remember that we have a pending sync request if this attempt failed
|
||||
syncRequestPending = !success;
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
@ -143,6 +146,10 @@ public class Synchronizer extends Thread {
|
||||
return this.isSynchronizing;
|
||||
}
|
||||
|
||||
public boolean isSyncRequestPending() {
|
||||
return this.syncRequestPending;
|
||||
}
|
||||
|
||||
public Integer getSyncPercent() {
|
||||
synchronized (this.syncLock) {
|
||||
return this.isSynchronizing ? this.syncPercent : null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user