Skip to content

Commit

Permalink
update inspector build
Browse files Browse the repository at this point in the history
  • Loading branch information
arnetheduck committed Aug 10, 2020
1 parent 134ef58 commit 5db23f7
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions beacon_chain/inspector.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import confutils, chronicles, chronos
import libp2p/[switch, standard_setup, multiaddress, multicodec, peerinfo]
import libp2p/crypto/crypto as lcrypto
import libp2p/crypto/secp as lsecp
import libp2p/protocols/pubsub/[pubsub, gossipsub]
import eth/p2p/discoveryv5/enr as enr
import eth/p2p/discoveryv5/[protocol, discovery_db, node]
import eth/keys as ethkeys, eth/trie/db
Expand Down Expand Up @@ -674,9 +675,14 @@ proc run(conf: InspectorConf) {.async.} =
error "Bind address is incorrect MultiAddress", address = conf.bindAddress
quit(1)

var switch = newStandardSwitch(some(seckey), hostAddress.get(),
triggerSelf = true, gossip = true,
sign = false, verifySignature = false, rng = rng)
let switch = newStandardSwitch(some(seckey), hostAddress.get(), rng = rng)

let pubsub = GossipSub.init(
switch = switch,
triggerSelf = true, sign = false,
verifySignature = false).PubSub

switch.mount(pubsub)

if len(conf.topics) > 0:
for item in conf.topics:
Expand Down Expand Up @@ -708,17 +714,18 @@ proc run(conf: InspectorConf) {.async.} =
data: seq[byte]): Future[void] {.gcsafe.} =
result = pubsubLogger(conf, switch, resolveQueue, topic, data)

discard switch.start()
discard await switch.start()
await pubsub.start()

var topicFilters = newSeq[string]()
try:
for filter in topics:
for topic in getTopics(forkDigest.get(), filter):
await switch.subscribe(topic, pubsubTrampoline)
await pubsub.subscribe(topic, pubsubTrampoline)
topicFilters.add(topic)
trace "Subscribed to topic", topic = topic
for filter in conf.customTopics:
await switch.subscribe(filter, pubsubTrampoline)
await pubsub.subscribe(filter, pubsubTrampoline)
topicFilters.add(filter)
trace "Subscribed to custom topic", topic = filter
except CatchableError as exc:
Expand Down

0 comments on commit 5db23f7

Please sign in to comment.