mirror of
https://github.com/status-im/nim-eth-p2p.git
synced 2025-02-19 18:18:23 +00:00
Specify debug enode through env var. Fail less often in discovery
This commit is contained in:
parent
2785dcdd19
commit
f89d2eee5f
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
import
|
import
|
||||||
tables, deques, macros, sets, algorithm, hashes, times,
|
tables, deques, macros, sets, algorithm, hashes, times,
|
||||||
random, options, sequtils, typetraits,
|
random, options, sequtils, typetraits, os,
|
||||||
asyncdispatch2, asyncdispatch2/timer,
|
asyncdispatch2, asyncdispatch2/timer,
|
||||||
rlp, ranges/[stackarrays, ptr_arith], nimcrypto, chronicles,
|
rlp, ranges/[stackarrays, ptr_arith], nimcrypto, chronicles,
|
||||||
eth_keys, eth_common,
|
eth_keys, eth_common,
|
||||||
@ -1388,7 +1388,10 @@ proc maybeConnectToMorePeers(p: PeerPool) {.async.} =
|
|||||||
if p.lastLookupTime + lookupInterval < epochTime():
|
if p.lastLookupTime + lookupInterval < epochTime():
|
||||||
ensureFuture p.lookupRandomNode()
|
ensureFuture p.lookupRandomNode()
|
||||||
|
|
||||||
# await p.connectToNode(newNode("enode://a52e914fa5aa46409e526a342a1e68b4e572c720e6eb1e61ad4a4201937679e7ebd26915bdabb2fdab6add7d85ba537078dbdccca89816a40ffc375572b6f73d@127.0.0.1:30303"))
|
let debugEnode = getEnv("ETH_DEBUG_ENODE")
|
||||||
|
if debugEnode.len != 0:
|
||||||
|
await p.connectToNode(newNode(debugEnode))
|
||||||
|
else:
|
||||||
await p.connectToNodes(p.nodesToConnect())
|
await p.connectToNodes(p.nodesToConnect())
|
||||||
|
|
||||||
# In some cases (e.g ROPSTEN or private testnets), the discovery table might
|
# In some cases (e.g ROPSTEN or private testnets), the discovery table might
|
||||||
|
@ -99,7 +99,10 @@ proc expiration(): uint32 =
|
|||||||
|
|
||||||
proc send(d: DiscoveryProtocol, n: Node, data: seq[byte]) =
|
proc send(d: DiscoveryProtocol, n: Node, data: seq[byte]) =
|
||||||
let ta = initTAddress(n.node.address.ip, n.node.address.udpPort)
|
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] =
|
proc sendPing*(d: DiscoveryProtocol, n: Node): seq[byte] =
|
||||||
let payload = rlp.encode((PROTO_VERSION, d.address, n.node.address,
|
let payload = rlp.encode((PROTO_VERSION, d.address, n.node.address,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user