Browse Source

Temporary fix to Controller to only try to acquire blockchain for incoming new unconfirmed transactions

pull/67/head
catbref 5 years ago
parent
commit
680361daa6
  1. 9
      src/main/java/org/qora/controller/Controller.java

9
src/main/java/org/qora/controller/Controller.java

@ -77,7 +77,7 @@ public class Controller extends Thread {
private final long buildTimestamp; // seconds private final long buildTimestamp; // seconds
/** Lock for only allowing one blockchain-modifying codepath at a time. e.g. synchronization or newly generated block. */ /** Lock for only allowing one blockchain-modifying codepath at a time. e.g. synchronization or newly generated block. */
private final ReentrantLock blockchainLock; private final ReentrantLock blockchainLock = new ReentrantLock();;
private Controller() { private Controller() {
Properties properties = new Properties(); Properties properties = new Properties();
@ -100,8 +100,6 @@ public class Controller extends Thread {
this.buildVersion = VERSION_PREFIX + buildVersion; this.buildVersion = VERSION_PREFIX + buildVersion;
LOGGER.info(String.format("Build version: %s", this.buildVersion)); LOGGER.info(String.format("Build version: %s", this.buildVersion));
blockchainLock = new ReentrantLock();
} }
public static Controller getInstance() { public static Controller getInstance() {
@ -583,7 +581,7 @@ public class Controller extends Thread {
// Blockchain lock required to prevent multiple threads trying to save the same transaction simultaneously // Blockchain lock required to prevent multiple threads trying to save the same transaction simultaneously
ReentrantLock blockchainLock = Controller.getInstance().getBlockchainLock(); ReentrantLock blockchainLock = Controller.getInstance().getBlockchainLock();
blockchainLock.lock(); if (blockchainLock.tryLock())
try { try {
// Do we have it already? // Do we have it already?
if (repository.getTransactionRepository().exists(transactionData.getSignature())) { if (repository.getTransactionRepository().exists(transactionData.getSignature())) {
@ -689,9 +687,6 @@ public class Controller extends Thread {
// Remove peers that have "misbehaved" recently // Remove peers that have "misbehaved" recently
peers.removeIf(hasPeerMisbehaved); peers.removeIf(hasPeerMisbehaved);
for (Peer peer : peers)
LOGGER.debug(String.format("Not up to date due to peer %s at height %d with block sig %s", peer, peer.getPeerData().getLastHeight(), Base58.encode(peer.getPeerData().getLastBlockSignature())));
// If we have any peers left, then they would be candidates for synchronization therefore we're not up to date. // If we have any peers left, then they would be candidates for synchronization therefore we're not up to date.
return peers.isEmpty(); return peers.isEmpty();
} }

Loading…
Cancel
Save