Specify debug enode through env var. Fail less often in discovery

This commit is contained in:
Yuriy Glukhov 2018-09-20 11:47:52 +03:00 committed by zah
parent 2785dcdd19
commit f89d2eee5f
2 changed files with 10 additions and 4 deletions

View File

@ -10,7 +10,7 @@
import
tables, deques, macros, sets, algorithm, hashes, times,
random, options, sequtils, typetraits,
random, options, sequtils, typetraits, os,
asyncdispatch2, asyncdispatch2/timer,
rlp, ranges/[stackarrays, ptr_arith], nimcrypto, chronicles,
eth_keys, eth_common,
@ -1388,8 +1388,11 @@ proc maybeConnectToMorePeers(p: PeerPool) {.async.} =
if p.lastLookupTime + lookupInterval < epochTime():
ensureFuture p.lookupRandomNode()
# await p.connectToNode(newNode("enode://a52e914fa5aa46409e526a342a1e68b4e572c720e6eb1e61ad4a4201937679e7ebd26915bdabb2fdab6add7d85ba537078dbdccca89816a40ffc375572b6f73d@127.0.0.1:30303"))
await p.connectToNodes(p.nodesToConnect())
let debugEnode = getEnv("ETH_DEBUG_ENODE")
if debugEnode.len != 0:
await p.connectToNode(newNode(debugEnode))
else:
await p.connectToNodes(p.nodesToConnect())
# In some cases (e.g ROPSTEN or private testnets), the discovery table might
# be full of bad peers, so if we can't connect to any peers we try a random

View File

@ -99,7 +99,10 @@ proc expiration(): uint32 =
proc send(d: DiscoveryProtocol, n: Node, data: seq[byte]) =
let ta = initTAddress(n.node.address.ip, n.node.address.udpPort)
asyncCheck d.transp.sendTo(ta, data)
let f = d.transp.sendTo(ta, data)
f.callback = proc(data: pointer) =
if f.failed:
error "Discovery send failed: ", f.readError.msg
proc sendPing*(d: DiscoveryProtocol, n: Node): seq[byte] =
let payload = rlp.encode((PROTO_VERSION, d.address, n.node.address,