Skip to content

Commit

Permalink
InboundConnectionsManager: Create address to connection mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
alvasw committed Apr 5, 2023
1 parent 75cf964 commit 6531253
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 6531253

Please sign in to comment.