Use the new enr.Record constructor

This commit is contained in:
Zahary Karadjov 2020-02-11 18:47:56 +02:00 committed by zah
parent a1a6862c7c
commit 9908e84935
1 changed files with 2 additions and 6 deletions

View File

@ -35,14 +35,10 @@ proc whoareyouMagic(toNode: NodeId): array[32, byte] =
proc newProtocol*(privKey: PrivateKey, db: Database, port: Port): Protocol = proc newProtocol*(privKey: PrivateKey, db: Database, port: Port): Protocol =
result = Protocol(privateKey: privKey, db: db) result = Protocol(privateKey: privKey, db: db)
var a: Address let a = Address(ip: parseIpAddress("127.0.0.1"), udpPort: port)
a.ip = parseIpAddress("127.0.0.1")
a.udpPort = port
var ipAddr: int32
bigEndian32(addr ipAddr, addr a.ip.address_v4)
result.localNode = newNode(initENode(result.privateKey.getPublicKey(), a)) result.localNode = newNode(initENode(result.privateKey.getPublicKey(), a))
result.localNode.record = initRecord(12, result.privateKey, {"udp": int(a.udpPort), "ip": ipAddr}) result.localNode.record = enr.Record.init(12, result.privateKey, a)
result.whoareyouMagic = whoareyouMagic(result.localNode.id) result.whoareyouMagic = whoareyouMagic(result.localNode.id)