From 6de3fb366a8b920bd1a830b43ff6a6af96e53315 Mon Sep 17 00:00:00 2001 From: Matilda Clerke Date: Wed, 25 Sep 2024 16:36:51 +1000 Subject: [PATCH] 7311: Use ConcurrentHashMap in DefaultPeerSelector Signed-off-by: Matilda Clerke --- .../ethereum/eth/manager/peertask/DefaultPeerSelector.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/DefaultPeerSelector.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/DefaultPeerSelector.java index 5d32a37bc8..37a6fd1895 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/DefaultPeerSelector.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/DefaultPeerSelector.java @@ -22,6 +22,7 @@ import java.util.Comparator; import java.util.HashMap; import java.util.Map; import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; import java.util.function.Predicate; import org.slf4j.Logger; @@ -34,9 +35,7 @@ import org.slf4j.LoggerFactory; public class DefaultPeerSelector implements PeerSelector { private static final Logger LOG = LoggerFactory.getLogger(DefaultPeerSelector.class); - // use a synchronized map to ensure the map is never modified by multiple threads at once - private final Map ethPeersByPeerId = - Collections.synchronizedMap(new HashMap<>()); + private final Map ethPeersByPeerId = new ConcurrentHashMap<>(); /** * Gets the highest reputation peer matching the supplied filter