From 8186a77d70b92323442b32b0e73a17d8318e4d0c Mon Sep 17 00:00:00 2001 From: Matilda Clerke Date: Wed, 9 Oct 2024 10:29:03 +1100 Subject: [PATCH] 7311: Rework getPeer again to use LEAST_TO_MOST_BUSY comparator Signed-off-by: Matilda Clerke --- .../org/hyperledger/besu/ethereum/eth/manager/EthPeers.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 d070c35ce1..09a998cf64 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 @@ -470,7 +470,10 @@ public class EthPeers implements PeerSelector { // Part of the PeerSelector interface, to be split apart later @Override public Optional getPeer(final Predicate filter) { - return streamBestPeers().filter(filter).filter(EthPeer::hasAvailableRequestCapacity).findFirst(); + return streamAvailablePeers() + .filter(filter) + .filter(EthPeer::hasAvailableRequestCapacity) + .min(LEAST_TO_MOST_BUSY); } // Part of the PeerSelector interface, to be split apart later