remove topics from pubsubpeer (was unused)

This commit is contained in:
Giovanni Petrantoni 2020-07-01 17:44:26 +09:00
parent d9e0ca6091
commit 4f5c97e27c
3 changed files with 0 additions and 20 deletions

View File

@ -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,

View File

@ -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

View File

@ -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