bump libp2p (#1031)

This commit is contained in:
Jacek Sieka 2020-05-18 10:11:21 +02:00 committed by GitHub
parent 24a17f5814
commit 6be7d64e8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 16 deletions

View File

@ -910,17 +910,19 @@ template tcpEndPoint(address, port): auto =
MultiAddress.init(address, Protocol.IPPROTO_TCP, port) MultiAddress.init(address, Protocol.IPPROTO_TCP, port)
proc getPersistentNetKeys*(conf: BeaconNodeConf): KeyPair = proc getPersistentNetKeys*(conf: BeaconNodeConf): KeyPair =
let privKeyPath = conf.dataDir / networkKeyFilename let
var privKey: PrivateKey privKeyPath = conf.dataDir / networkKeyFilename
if not fileExists(privKeyPath): privKey =
createDir conf.dataDir.string if not fileExists(privKeyPath):
privKey = PrivateKey.random(Secp256k1) createDir conf.dataDir.string
writeFile(privKeyPath, privKey.getBytes()) let key = PrivateKey.random(Secp256k1).tryGet()
else: writeFile(privKeyPath, key.getBytes().tryGet())
let keyBytes = readFile(privKeyPath) key
privKey = PrivateKey.init(keyBytes.toOpenArrayByte(0, keyBytes.high)) else:
let keyBytes = readFile(privKeyPath)
PrivateKey.init(keyBytes.toOpenArrayByte(0, keyBytes.high)).tryGet()
KeyPair(seckey: privKey, pubkey: privKey.getKey()) KeyPair(seckey: privKey, pubkey: privKey.getKey().tryGet())
proc createEth2Node*(conf: BeaconNodeConf, enrForkId: ENRForkID): Future[Eth2Node] {.async, gcsafe.} = proc createEth2Node*(conf: BeaconNodeConf, enrForkId: ENRForkID): Future[Eth2Node] {.async, gcsafe.} =
var var

View File

@ -316,10 +316,10 @@ proc init*(p: typedesc[PeerInfo],
if trecOpt.isSome(): if trecOpt.isSome():
trec = trecOpt.get() trec = trecOpt.get()
if trec.secp256k1.isSome(): if trec.secp256k1.isSome():
var skpubkey: SkPublicKey let skpubkey = SkPublicKey.fromRaw(trec.secp256k1.get())
if skpubkey.init(trec.secp256k1.get()): if skpubkey.isOk():
let peerid = PeerID.init(PublicKey(scheme: Secp256k1, let peerid = PeerID.init(PublicKey(scheme: Secp256k1,
skkey: skpubkey)) skkey: skpubkey[]))
var mas = newSeq[MultiAddress]() var mas = newSeq[MultiAddress]()
if trec.ip.isSome() and trec.tcp.isSome(): if trec.ip.isSome() and trec.tcp.isSome():
let ma = MultiAddress.init(multiCodec("ip4"), trec.ip.get()) & let ma = MultiAddress.init(multiCodec("ip4"), trec.ip.get()) &
@ -411,7 +411,7 @@ proc bootstrapDiscovery(conf: InspectorConf,
privkey: lcrypto.PrivateKey, privkey: lcrypto.PrivateKey,
bootnodes: seq[enr.Record], bootnodes: seq[enr.Record],
enrFields: Option[ENRFieldPair]): DiscoveryProtocol = enrFields: Option[ENRFieldPair]): DiscoveryProtocol =
var pk = ethkeys.PrivateKey.fromRaw(privkey.getBytes()).tryGet() var pk = ethkeys.PrivateKey(privkey.skkey)
var db = DiscoveryDB.init(newMemoryDB()) var db = DiscoveryDB.init(newMemoryDB())
let udpPort = Port(conf.discoveryPort) let udpPort = Port(conf.discoveryPort)
let tcpPort = Port(conf.ethPort) let tcpPort = Port(conf.ethPort)
@ -684,7 +684,7 @@ proc run(conf: InspectorConf) {.async.} =
bootstrap_fork_digest = forkDigest.get() bootstrap_fork_digest = forkDigest.get()
forkDigest = argForkDigest forkDigest = argForkDigest
let seckey = lcrypto.PrivateKey.random(PKScheme.Secp256k1) let seckey = lcrypto.PrivateKey.random(PKScheme.Secp256k1).tryGet()
# let pubkey = seckey.getKey() # let pubkey = seckey.getKey()
let hostAddress = tryGetMultiAddress(conf.bindAddress) let hostAddress = tryGetMultiAddress(conf.bindAddress)

2
vendor/nim-libp2p vendored

@ -1 +1 @@
Subproject commit 5abbcfb5eb85826b1a141f7035bc17fc6e8a949a Subproject commit 7dcb807f647a9f979820de5d450f17492f2e0ed5