Skip to content

Commit

Permalink
Merge pull request #710 from alvasw/inbound_connections_manager_map_a…
Browse files Browse the repository at this point in the history
…ddress_to_connection

InboundConnectionsManager: Create address to connection mapping
  • Loading branch information
alvasw authored Apr 5, 2023
2 parents 75cf964 + 6531253 commit 1fd7028
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@

import java.io.IOException;
import java.nio.channels.*;
import java.util.*;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;

Expand All @@ -42,6 +45,7 @@ public class InboundConnectionsManager {
private final List<SocketChannel> inboundHandshakeChannels = new CopyOnWriteArrayList<>();
private final List<SocketChannel> verifiedConnections = new CopyOnWriteArrayList<>();
private final Map<SocketChannel, InboundConnectionChannel> connectionByChannel = new ConcurrentHashMap<>();
private final Map<Address, InboundConnectionChannel> connectionByAddress = new ConcurrentHashMap<>();

public InboundConnectionsManager(BanList banList,
Capability myCapability,
Expand Down Expand Up @@ -108,6 +112,7 @@ public void handleInboundConnection(SocketChannel socketChannel, List<NetworkEnv
closeChannel(networkEnvelopeSocketChannel);
} else {
connectionByChannel.put(socketChannel, inboundConnection);
connectionByAddress.put(peerAddress, inboundConnection);
verifiedConnections.add(socketChannel);

log.info("Calling node.onNewIncomingConnection for peer {}", peerAddress.getFullAddress());
Expand Down

0 comments on commit 1fd7028

Please sign in to comment.