Allow 3 seconds for the synchronizer to obtain a blockchain lock, to reduce missed attempts.

This commit is contained in:
CalDescent 2022-01-30 17:11:30 +00:00
parent 170244e679
commit 60d71863dc

View File

@ -5,6 +5,7 @@ import java.security.SecureRandom;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
@ -862,7 +863,7 @@ public class Synchronizer extends Thread {
// Make sure we're the only thread modifying the blockchain
// If we're already synchronizing with another peer then this will also return fast
ReentrantLock blockchainLock = Controller.getInstance().getBlockchainLock();
if (!blockchainLock.tryLock()) {
if (!blockchainLock.tryLock(3, TimeUnit.SECONDS))
// Wasn't peer's fault we couldn't sync
LOGGER.debug("Synchronizer couldn't acquire blockchain lock");
return SynchronizationResult.NO_BLOCKCHAIN_LOCK;