forked from Qortal/qortal
Revert "Remove peers with unknown height, lower height or same height and same block signature (unless we don't have their block signature)"
This reverts commit 895f02f17896c5ad78f7e8f26252d7530aae3a85.
This commit is contained in:
parent
568497e1c5
commit
46701e4de7
@ -660,29 +660,6 @@ public class Controller extends Thread {
|
|||||||
return lastMisbehaved != null && lastMisbehaved > NTP.getTime() - MISBEHAVIOUR_COOLOFF;
|
return lastMisbehaved != null && lastMisbehaved > NTP.getTime() - MISBEHAVIOUR_COOLOFF;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** True if peer has unknown height, lower height or same height and same block signature (unless we don't have their block signature). */
|
|
||||||
public static Predicate<Peer> hasShorterBlockchain = peer -> {
|
|
||||||
BlockData highestBlockData = getInstance().getChainTip();
|
|
||||||
int ourHeight = highestBlockData.getHeight();
|
|
||||||
final PeerChainTipData peerChainTipData = peer.getChainTipData();
|
|
||||||
|
|
||||||
// Ensure we have chain tip data for this peer
|
|
||||||
if (peerChainTipData == null)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// Remove if peer is at a lower height than us
|
|
||||||
Integer peerHeight = peerChainTipData.getLastHeight();
|
|
||||||
if (peerHeight == null || peerHeight < ourHeight)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// Don't remove if peer is on a greater height chain than us, or if we don't have their block signature
|
|
||||||
if (peerHeight > ourHeight || peerChainTipData.getLastBlockSignature() == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Remove if signatures match
|
|
||||||
return Arrays.equals(peerChainTipData.getLastBlockSignature(), highestBlockData.getSignature());
|
|
||||||
};
|
|
||||||
|
|
||||||
public static final Predicate<Peer> hasNoRecentBlock = peer -> {
|
public static final Predicate<Peer> hasNoRecentBlock = peer -> {
|
||||||
final Long minLatestBlockTimestamp = getMinimumLatestBlockTimestamp();
|
final Long minLatestBlockTimestamp = getMinimumLatestBlockTimestamp();
|
||||||
final PeerChainTipData peerChainTipData = peer.getChainTipData();
|
final PeerChainTipData peerChainTipData = peer.getChainTipData();
|
||||||
|
@ -235,9 +235,6 @@ public class Synchronizer extends Thread {
|
|||||||
// Disregard peers that are on the same block as last sync attempt and we didn't like their chain
|
// Disregard peers that are on the same block as last sync attempt and we didn't like their chain
|
||||||
peers.removeIf(Controller.hasInferiorChainTip);
|
peers.removeIf(Controller.hasInferiorChainTip);
|
||||||
|
|
||||||
// Remove peers with unknown height, lower height or same height and same block signature (unless we don't have their block signature)
|
|
||||||
peers.removeIf(Controller.hasShorterBlockchain);
|
|
||||||
|
|
||||||
final int peersBeforeComparison = peers.size();
|
final int peersBeforeComparison = peers.size();
|
||||||
|
|
||||||
// Request recent block summaries from the remaining peers, and locate our common block with each
|
// Request recent block summaries from the remaining peers, and locate our common block with each
|
||||||
|
Loading…
x
Reference in New Issue
Block a user