Skip to content

Commit

Permalink
ETCM-207: Pass the localNodeAddress to DiscoveryNetwork.
Browse files Browse the repository at this point in the history
  • Loading branch information
aakoshh committed Oct 20, 2020
1 parent 08c36b9 commit 5e9e33f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
Expand Up @@ -66,6 +66,7 @@ class DiscoveryKademliaIntegrationSpec extends KademliaIntegrationSpec("Discover
DiscoveryNetwork[InetMultiAddress](
peerGroup,
privateKey,
localNodeAddress = selfNode.address,
toNodeAddress = inetMultiAddressToNodeAddress,
config = config
)
Expand Down
Expand Up @@ -52,6 +52,8 @@ object DiscoveryNetwork {
def apply[A](
peerGroup: PeerGroup[A, Packet],
privateKey: PrivateKey,
// Sent in pings; some clients use the the TCP port in the `from` so it should be accurate.
localNodeAddress: Node.Address,
toNodeAddress: A => Node.Address,
config: DiscoveryConfig
)(implicit codec: Codec[Payload], sigalg: SigAlg, clock: Clock[Task]): Task[DiscoveryNetwork[A]] = Task {
Expand All @@ -66,9 +68,6 @@ object DiscoveryNetwork {

private val maxNeighborsPerPacket = getMaxNeighborsPerPacket

// This is only sent in Ping packets and is basically ignored by nodes.
private val localNodeAddress = toNodeAddress(peerGroup.processAddress)

/** Start a fiber that accepts incoming channels and starts a dedicated fiber
* to handle every channel separtely, processing their messages one by one.
* This is fair: every remote connection can be throttled independently
Expand Down
Expand Up @@ -837,6 +837,7 @@ object DiscoveryNetworkSpec extends Matchers {
DiscoveryNetwork[InetSocketAddress](
peerGroup = peerGroup,
privateKey = privateKey,
localNodeAddress = toNodeAddress(localAddress),
toNodeAddress = toNodeAddress,
config = config
).runSyncUnsafe()
Expand Down

0 comments on commit 5e9e33f

Please sign in to comment.