In Controller.processIncomingTransactionsQueue(), don't bother with 2nd-phase of locking blockchain and importing if there are no valid signature transactions to actually import

This commit is contained in:
catbref 2022-03-03 20:32:27 +00:00
parent affd100298
commit a9371f0a90

View File

@ -847,7 +847,7 @@ public class Controller extends Thread {
private void processIncomingTransactionsQueue() { private void processIncomingTransactionsQueue() {
if (this.incomingTransactions.isEmpty()) { if (this.incomingTransactions.isEmpty()) {
// Don't bother locking if there are no new transactions to process // Nothing to do?
return; return;
} }
@ -912,6 +912,11 @@ public class Controller extends Thread {
sigValidTransactions.add(transaction); sigValidTransactions.add(transaction);
} }
if (sigValidTransactions.isEmpty()) {
// Don't bother locking if there are no new transactions to process
return;
}
try { try {
ReentrantLock blockchainLock = Controller.getInstance().getBlockchainLock(); ReentrantLock blockchainLock = Controller.getInstance().getBlockchainLock();
if (!blockchainLock.tryLock(2, TimeUnit.SECONDS)) { if (!blockchainLock.tryLock(2, TimeUnit.SECONDS)) {