Synchronize hasInvalidBlock predicate, as it wasn't thread safe

This commit is contained in:
CalDescent 2022-06-25 14:12:21 +01:00
parent 7e1ce38f0a
commit a2e1efab90
2 changed files with 29 additions and 27 deletions

View File

@ -723,6 +723,7 @@ public class Controller extends Thread {
};
public static final Predicate<Peer> hasInvalidBlock = peer -> {
synchronized (peer.peerInfoLock) {
final PeerChainTipData peerChainTipData = peer.getChainTipData();
Map<ByteArray, Long> invalidBlockSignatures = Synchronizer.getInstance().getInvalidBlockSignatures();
List<byte[]> peerSignatures = new ArrayList<>();
@ -756,6 +757,7 @@ public class Controller extends Thread {
}
}
return false;
}
};
public static final Predicate<Peer> hasNoRecentBlock = peer -> {

View File

@ -121,7 +121,7 @@ public class Peer {
// Peer info
private final Object peerInfoLock = new Object();
public final Object peerInfoLock = new Object();
private String peersNodeId;
private byte[] peersPublicKey;