remove topics from pubsubpeer (was unused)
This commit is contained in:
parent
d9e0ca6091
commit
4f5c97e27c
|
@ -28,7 +28,6 @@ declareGauge(libp2p_pubsub_topics, "pubsub subscribed topics")
|
||||||
declareCounter(libp2p_pubsub_validation_success, "pubsub successfully validated messages")
|
declareCounter(libp2p_pubsub_validation_success, "pubsub successfully validated messages")
|
||||||
declareCounter(libp2p_pubsub_validation_failure, "pubsub failed validated messages")
|
declareCounter(libp2p_pubsub_validation_failure, "pubsub failed validated messages")
|
||||||
declarePublicCounter(libp2p_pubsub_messages_published, "published messages", labels = ["topic"])
|
declarePublicCounter(libp2p_pubsub_messages_published, "published messages", labels = ["topic"])
|
||||||
declareGauge(libp2p_pubsub_peers_per_topic, "pubsub peers per topic", labels = ["topic"])
|
|
||||||
|
|
||||||
type
|
type
|
||||||
TopicHandler* = proc(topic: string,
|
TopicHandler* = proc(topic: string,
|
||||||
|
@ -84,23 +83,6 @@ method subscribeTopic*(p: PubSub,
|
||||||
if isNil(peer) or isNil(peer.peerInfo): # should not happen
|
if isNil(peer) or isNil(peer.peerInfo): # should not happen
|
||||||
if subscribe:
|
if subscribe:
|
||||||
warn "subscribeTopic but peer was unknown!"
|
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,
|
method rpcHandler*(p: PubSub,
|
||||||
peer: PubSubPeer,
|
peer: PubSubPeer,
|
||||||
|
|
|
@ -36,7 +36,6 @@ type
|
||||||
sendConn: Connection
|
sendConn: Connection
|
||||||
peerInfo*: PeerInfo
|
peerInfo*: PeerInfo
|
||||||
handler*: RPCHandler
|
handler*: RPCHandler
|
||||||
topics*: seq[string]
|
|
||||||
sentRpcCache: TimedCache[string] # cache for already sent messages
|
sentRpcCache: TimedCache[string] # cache for already sent messages
|
||||||
recvdRpcCache: TimedCache[string] # cache for already received messages
|
recvdRpcCache: TimedCache[string] # cache for already received messages
|
||||||
refs*: int # refcount of the connections this peer is handling
|
refs*: int # refcount of the connections this peer is handling
|
||||||
|
|
|
@ -99,7 +99,6 @@ suite "GossipSub internal":
|
||||||
conn.peerInfo = peerInfo
|
conn.peerInfo = peerInfo
|
||||||
gossipSub.peers[peerInfo.id] = newPubSubPeer(peerInfo, GossipSubCodec)
|
gossipSub.peers[peerInfo.id] = newPubSubPeer(peerInfo, GossipSubCodec)
|
||||||
gossipSub.peers[peerInfo.id].handler = handler
|
gossipSub.peers[peerInfo.id].handler = handler
|
||||||
gossipSub.peers[peerInfo.id].topics &= topic
|
|
||||||
gossipSub.gossipsub[topic].incl(peerInfo.id)
|
gossipSub.gossipsub[topic].incl(peerInfo.id)
|
||||||
|
|
||||||
check gossipSub.gossipsub[topic].len == 15
|
check gossipSub.gossipsub[topic].len == 15
|
||||||
|
|
Loading…
Reference in New Issue