From 5d8449dff0c342a76b3338a728c7a8eb53204ed4 Mon Sep 17 00:00:00 2001 From: Danno Ferrin Date: Wed, 27 Jan 2021 01:13:51 -0700 Subject: [PATCH] Update peer validation (#1838) * Update peer validation Change the location where peer validation is checked for height estimates. Too early and all of peer discovery is stopped. Signed-off-by: Danno Ferrin --- .../org/hyperledger/besu/ethereum/eth/manager/EthPeer.java | 4 +--- .../org/hyperledger/besu/ethereum/eth/manager/EthPeers.java | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthPeer.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthPeer.java index 4b44c9df4c..b2b547c456 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthPeer.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthPeer.java @@ -331,9 +331,7 @@ public class EthPeer { * @return true if the peer is ready to accept requests for data. */ public boolean readyForRequests() { - return statusHasBeenSentToPeer.get() - && statusHasBeenReceivedFromPeer.get() - && fullyValidated.get(); + return statusHasBeenSentToPeer.get() && statusHasBeenReceivedFromPeer.get(); } /** diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthPeers.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthPeers.java index 02ad3a1979..1c5719b000 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthPeers.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthPeers.java @@ -153,7 +153,8 @@ public class EthPeers { } public Optional bestPeerWithHeightEstimate() { - return bestPeerMatchingCriteria(p -> p.chainState().hasEstimatedHeight()); + return bestPeerMatchingCriteria( + p -> p.isFullyValidated() && p.chainState().hasEstimatedHeight()); } public Optional bestPeerMatchingCriteria(final Predicate matchesCriteria) {