From 4f5c97e27cdee87b1d970f7c36e9d9969061bce7 Mon Sep 17 00:00:00 2001 From: Giovanni Petrantoni Date: Wed, 1 Jul 2020 17:44:26 +0900 Subject: [PATCH] remove topics from pubsubpeer (was unused) --- libp2p/protocols/pubsub/pubsub.nim | 18 ------------------ libp2p/protocols/pubsub/pubsubpeer.nim | 1 - tests/pubsub/testgossipinternal.nim | 1 - 3 files changed, 20 deletions(-) diff --git a/libp2p/protocols/pubsub/pubsub.nim b/libp2p/protocols/pubsub/pubsub.nim index 197b5d4d0..3c0ab4243 100644 --- a/libp2p/protocols/pubsub/pubsub.nim +++ b/libp2p/protocols/pubsub/pubsub.nim @@ -28,7 +28,6 @@ declareGauge(libp2p_pubsub_topics, "pubsub subscribed topics") declareCounter(libp2p_pubsub_validation_success, "pubsub successfully validated messages") declareCounter(libp2p_pubsub_validation_failure, "pubsub failed validated messages") declarePublicCounter(libp2p_pubsub_messages_published, "published messages", labels = ["topic"]) -declareGauge(libp2p_pubsub_peers_per_topic, "pubsub peers per topic", labels = ["topic"]) type TopicHandler* = proc(topic: string, @@ -84,23 +83,6 @@ method subscribeTopic*(p: PubSub, if isNil(peer) or isNil(peer.peerInfo): # should not happen if subscribe: warn "subscribeTopic but peer was unknown!" - return # Stop causing bad metrics! - else: - return # Stop causing bad metrics! - - let idx = peer.topics.find(topic) - if subscribe: - libp2p_pubsub_peers_per_topic.inc(labelValues = [topic]) - if idx == -1: - peer.topics &= topic - else: - warn "subscribe but topic was already previously subscribed", topic, peer = peerId - else: - libp2p_pubsub_peers_per_topic.dec(labelValues = [topic]) - if idx == -1: - warn "unsubscribe but topic was not previously subscribed", topic, peer = peerId - else: - peer.topics.del(idx) method rpcHandler*(p: PubSub, peer: PubSubPeer, diff --git a/libp2p/protocols/pubsub/pubsubpeer.nim b/libp2p/protocols/pubsub/pubsubpeer.nim index fa2c5c5ae..e73d2e073 100644 --- a/libp2p/protocols/pubsub/pubsubpeer.nim +++ b/libp2p/protocols/pubsub/pubsubpeer.nim @@ -36,7 +36,6 @@ type sendConn: Connection peerInfo*: PeerInfo handler*: RPCHandler - topics*: seq[string] sentRpcCache: TimedCache[string] # cache for already sent messages recvdRpcCache: TimedCache[string] # cache for already received messages refs*: int # refcount of the connections this peer is handling diff --git a/tests/pubsub/testgossipinternal.nim b/tests/pubsub/testgossipinternal.nim index 4460c7672..35b6bdd1b 100644 --- a/tests/pubsub/testgossipinternal.nim +++ b/tests/pubsub/testgossipinternal.nim @@ -99,7 +99,6 @@ suite "GossipSub internal": conn.peerInfo = peerInfo gossipSub.peers[peerInfo.id] = newPubSubPeer(peerInfo, GossipSubCodec) gossipSub.peers[peerInfo.id].handler = handler - gossipSub.peers[peerInfo.id].topics &= topic gossipSub.gossipsub[topic].incl(peerInfo.id) check gossipSub.gossipsub[topic].len == 15