forked from Qortal/qortal
Removed hasInvalidBlock filtering, as this was unnecessary risk now that the original bug in comparePeers() is fixed.
This commit is contained in:
parent
4440e82bb9
commit
a01652b816
@ -722,44 +722,6 @@ public class Controller extends Thread {
|
||||
return lastMisbehaved != null && lastMisbehaved > NTP.getTime() - MISBEHAVIOUR_COOLOFF;
|
||||
};
|
||||
|
||||
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<>();
|
||||
|
||||
// Add peer's latest block signature
|
||||
if (peerChainTipData != null) {
|
||||
peerSignatures.add(peerChainTipData.getLastBlockSignature());
|
||||
}
|
||||
|
||||
// Add peer's blocks since common block
|
||||
if (peer.getCommonBlockData() != null) {
|
||||
List<BlockSummaryData> peerSummaries = peer.getCommonBlockData().getBlockSummariesAfterCommonBlock();
|
||||
if (peerSummaries != null) {
|
||||
for (BlockSummaryData blockSummaryData : peerSummaries) {
|
||||
peerSignatures.add(blockSummaryData.getSignature());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Shortcut if no data
|
||||
if (peerSignatures.isEmpty() || invalidBlockSignatures == null || invalidBlockSignatures.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Loop through our known invalid blocks and check each one against supplied block summaries
|
||||
for (ByteArray invalidSignature : invalidBlockSignatures.keySet()) {
|
||||
for (byte[] peerSignature : peerSignatures) {
|
||||
if (Arrays.equals(peerSignature, invalidSignature.value)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
public static final Predicate<Peer> hasNoRecentBlock = peer -> {
|
||||
final Long minLatestBlockTimestamp = getMinimumLatestBlockTimestamp();
|
||||
final PeerChainTipData peerChainTipData = peer.getChainTipData();
|
||||
|
@ -241,10 +241,6 @@ public class Synchronizer extends Thread {
|
||||
// Compare the peers against each other, and against our chain, which will return an updated list excluding those without common blocks
|
||||
peers = Synchronizer.getInstance().comparePeers(peers);
|
||||
|
||||
// Disregard peers that hold invalid blocks
|
||||
// Make sure this is after findCommonBlocksWithPeers() so that peers' summaries can be updated
|
||||
peers.removeIf(Controller.hasInvalidBlock);
|
||||
|
||||
// We may have added more inferior chain tips when comparing peers, so remove any peers that are currently on those chains
|
||||
peers.removeIf(Controller.hasInferiorChainTip);
|
||||
|
||||
|
@ -121,7 +121,7 @@ public class Peer {
|
||||
|
||||
// Peer info
|
||||
|
||||
public final Object peerInfoLock = new Object();
|
||||
private final Object peerInfoLock = new Object();
|
||||
|
||||
private String peersNodeId;
|
||||
private byte[] peersPublicKey;
|
||||
|
Loading…
x
Reference in New Issue
Block a user