always enable topic and aggreate metric topics (#2229)

This commit is contained in:
Giovanni Petrantoni 2021-01-12 12:27:09 +09:00 committed by GitHub
parent 6653ce3fc5
commit a3a651b565
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -1591,11 +1591,17 @@ proc announcedENR*(node: Eth2Node): enr.Record =
proc shortForm*(id: KeyPair): string =
$PeerID.init(id.pubkey)
proc subscribe*(node: Eth2Node, topic: string) =
proc subscribe*(node: Eth2Node, topic: string, enableTopicMetrics: bool = false) =
proc dummyMsgHandler(topic: string, data: seq[byte]) {.async.} =
discard
node.pubsub.subscribe(topic & "_snappy", dummyMsgHandler)
let
topicName = topic & "_snappy"
if enableTopicMetrics:
node.pubsub.knownTopics.incl(topicName)
node.pubsub.subscribe(topicName, dummyMsgHandler)
proc addValidator*[MsgType](node: Eth2Node,
topic: string,

View File

@ -475,11 +475,11 @@ proc getAttestationSubnetHandlers(node: BeaconNode) =
proc addMessageHandlers(node: BeaconNode) =
# As a side-effect, this gets the attestation subnets too.
node.network.subscribe(node.topicBeaconBlocks)
node.network.subscribe(node.topicBeaconBlocks, enableTopicMetrics = true)
node.network.subscribe(getAttesterSlashingsTopic(node.forkDigest))
node.network.subscribe(getProposerSlashingsTopic(node.forkDigest))
node.network.subscribe(getVoluntaryExitsTopic(node.forkDigest))
node.network.subscribe(getAggregateAndProofsTopic(node.forkDigest))
node.network.subscribe(getAggregateAndProofsTopic(node.forkDigest), enableTopicMetrics = true)
node.getAttestationSubnetHandlers()