Skip to content

Commit

Permalink
7311: Use ConcurrentHashMap in DefaultPeerSelector
Browse files Browse the repository at this point in the history
Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>
  • Loading branch information
Matilda-Clerke committed Sep 25, 2024
1 parent 38f04ab commit 6de3fb3
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
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;
Expand All @@ -34,9 +35,7 @@
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<PeerId, EthPeer> ethPeersByPeerId =
Collections.synchronizedMap(new HashMap<>());
private final Map<PeerId, EthPeer> ethPeersByPeerId = new ConcurrentHashMap<>();

/**
* Gets the highest reputation peer matching the supplied filter
Expand Down

0 comments on commit 6de3fb3

Please sign in to comment.