mirror of https://github.com/status-im/nim-eth.git
Move dcli tool to a tools folder (#584)
This commit is contained in:
parent
20d2d318f0
commit
4d55bfc9e8
|
@ -239,7 +239,7 @@ jobs:
|
||||||
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib"
|
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib"
|
||||||
nim --version
|
nim --version
|
||||||
nimble --version
|
nimble --version
|
||||||
nimble install -y --depsOnly
|
nimble install -y
|
||||||
nimble test
|
nimble test
|
||||||
nimble build_dcli
|
nimble build_dcli
|
||||||
nimble build_fuzzers
|
nimble build_fuzzers
|
||||||
|
|
|
@ -106,7 +106,7 @@ task test_discv5_full, "Run discovery v5 and its dependencies tests":
|
||||||
test_discv5_task()
|
test_discv5_task()
|
||||||
|
|
||||||
task build_dcli, "Build dcli":
|
task build_dcli, "Build dcli":
|
||||||
buildBinary("eth/p2p/discoveryv5/dcli")
|
buildBinary("tools/dcli")
|
||||||
|
|
||||||
import os, strutils
|
import os, strutils
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,9 @@ import
|
||||||
std/[options, strutils, tables, sets],
|
std/[options, strutils, tables, sets],
|
||||||
confutils, confutils/std/net, chronicles, chronicles/topics_registry,
|
confutils, confutils/std/net, chronicles, chronicles/topics_registry,
|
||||||
chronos, metrics, metrics/chronos_httpserver, stew/byteutils, stew/bitops2,
|
chronos, metrics, metrics/chronos_httpserver, stew/byteutils, stew/bitops2,
|
||||||
../../keys, ../../net/nat,
|
./eth/keys, ./eth/net/nat,
|
||||||
"."/[enr, node],
|
./eth/p2p/discoveryv5/[enr, node],
|
||||||
"."/protocol as discv5_protocol
|
./eth/p2p/discoveryv5/protocol as discv5_protocol
|
||||||
|
|
||||||
type
|
type
|
||||||
DiscoveryCmd* = enum
|
DiscoveryCmd* = enum
|
||||||
|
@ -145,34 +145,34 @@ proc discover(d: discv5_protocol.Protocol, psFile: string) {.async.} =
|
||||||
let ps = open(psFile, fmWrite)
|
let ps = open(psFile, fmWrite)
|
||||||
defer: ps.close()
|
defer: ps.close()
|
||||||
ps.write("pubkey,node_id,fork_digest,ip:port,attnets,attnets_number\n")
|
ps.write("pubkey,node_id,fork_digest,ip:port,attnets,attnets_number\n")
|
||||||
|
|
||||||
while true:
|
while true:
|
||||||
let iTime = now(chronos.Moment)
|
let iTime = now(chronos.Moment)
|
||||||
let discovered = await d.queryRandom()
|
let discovered = await d.queryRandom()
|
||||||
let qDuration = now(chronos.Moment) - iTime
|
let qDuration = now(chronos.Moment) - iTime
|
||||||
info "Lookup finished", query_time = qDuration.secs, new_nodes = discovered.len, tot_peers=len(ethNodes)
|
info "Lookup finished", query_time = qDuration.secs, new_nodes = discovered.len, tot_peers=len(ethNodes)
|
||||||
|
|
||||||
for dNode in discovered:
|
for dNode in discovered:
|
||||||
let eth2 = dNode.record.tryGet("eth2", seq[byte])
|
let eth2 = dNode.record.tryGet("eth2", seq[byte])
|
||||||
let pubkey = dNode.record.tryGet("secp256k1", seq[byte])
|
let pubkey = dNode.record.tryGet("secp256k1", seq[byte])
|
||||||
let attnets = dNode.record.tryGet("attnets", seq[byte])
|
let attnets = dNode.record.tryGet("attnets", seq[byte])
|
||||||
if eth2.isNone or attnets.isNone or pubkey.isNone: continue
|
if eth2.isNone or attnets.isNone or pubkey.isNone: continue
|
||||||
|
|
||||||
if pubkey.get() in ethNodes: continue
|
if pubkey.get() in ethNodes: continue
|
||||||
ethNodes.incl(pubkey.get())
|
ethNodes.incl(pubkey.get())
|
||||||
|
|
||||||
let forkDigest = eth2.get()
|
let forkDigest = eth2.get()
|
||||||
|
|
||||||
var bits = 0
|
var bits = 0
|
||||||
for byt in attnets.get():
|
for byt in attnets.get():
|
||||||
bits.inc(countOnes(byt.uint))
|
bits.inc(countOnes(byt.uint))
|
||||||
|
|
||||||
let str = "$#,$#,$#,$#,$#,$#\n"
|
let str = "$#,$#,$#,$#,$#,$#\n"
|
||||||
let newLine = str % [pubkey.get().toHex, dNode.id.toHex, forkDigest[0..3].toHex, $dNode.address.get(), attnets.get().toHex, $bits]
|
let newLine = str % [pubkey.get().toHex, dNode.id.toHex, forkDigest[0..3].toHex, $dNode.address.get(), attnets.get().toHex, $bits]
|
||||||
|
|
||||||
ps.write(newLine)
|
ps.write(newLine)
|
||||||
await sleepAsync(1000) # 1 sec of delay
|
await sleepAsync(1000) # 1 sec of delay
|
||||||
|
|
||||||
|
|
||||||
proc run(config: DiscoveryConf) =
|
proc run(config: DiscoveryConf) =
|
||||||
let
|
let
|
Loading…
Reference in New Issue