7311: Rework getPeer again to use LEAST_TO_MOST_BUSY comparator

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>
pull/7628/head
Matilda Clerke 2 months ago
parent 8becdb3ef5
commit 8186a77d70
  1. 5
      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<EthPeer> getPeer(final Predicate<EthPeer> 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

Loading…
Cancel
Save