mirror of https://github.com/status-im/nim-eth.git
[discv5] Advertise the LibP2P TCP port properly
This commit is contained in:
parent
cca931d0b5
commit
cfdb26db40
|
@ -33,9 +33,12 @@ proc whoareyouMagic(toNode: NodeId): array[32, byte] =
|
|||
for i, c in prefix: data[sizeof(toNode) + i] = byte(c)
|
||||
sha256.digest(data).data
|
||||
|
||||
proc newProtocol*(privKey: PrivateKey, db: Database, port: Port): Protocol =
|
||||
proc newProtocol*(privKey: PrivateKey,
|
||||
db: Database,
|
||||
tcpPort, udpPort: Port): Protocol =
|
||||
result = Protocol(privateKey: privKey, db: db)
|
||||
let a = Address(ip: parseIpAddress("127.0.0.1"), udpPort: port)
|
||||
let a = Address(ip: parseIpAddress("127.0.0.1"),
|
||||
tcpPort: tcpPort, udpPort: udpPort)
|
||||
|
||||
result.localNode = newNode(initENode(result.privateKey.getPublicKey(), a))
|
||||
result.localNode.record = enr.Record.init(12, result.privateKey, a)
|
||||
|
@ -364,7 +367,8 @@ when isMainModule:
|
|||
else:
|
||||
pk = newPrivateKey()
|
||||
|
||||
let d = newProtocol(pk, DiscoveryDB.init(newMemoryDB()), Port(12001 + i))
|
||||
let d = newProtocol(pk, DiscoveryDB.init(newMemoryDB()),
|
||||
Port(12001 + i), Port(12001 + i))
|
||||
d.open()
|
||||
result.add(d)
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@ var nextPort = 30303
|
|||
|
||||
proc localAddress*(port: int): Address =
|
||||
let port = Port(port)
|
||||
result = Address(udpPort: port, tcpPort: port, ip: parseIpAddress("127.0.0.1"))
|
||||
result = Address(udpPort: port, tcpPort: port,
|
||||
ip: parseIpAddress("127.0.0.1"))
|
||||
|
||||
proc startDiscoveryNode*(privKey: PrivateKey, address: Address,
|
||||
bootnodes: seq[ENode]): Future[DiscoveryProtocol] {.async.} =
|
||||
|
|
|
@ -8,7 +8,7 @@ import
|
|||
proc startDiscoveryv5Node*(privKey: PrivateKey, address: Address,
|
||||
bootnodes: seq[Record]): discv5_protocol.Protocol =
|
||||
var db = DiscoveryDB.init(newMemoryDB())
|
||||
result = newProtocol(privKey, db, address.udpPort)
|
||||
result = newProtocol(privKey, db, address.tcpPort, address.udpPort)
|
||||
|
||||
for node in bootnodes:
|
||||
result.addNode(node)
|
||||
|
|
Loading…
Reference in New Issue