mirror of https://github.com/vacp2p/nim-libp2p.git
fix control messages (#566)
* remove unused control graft check in handleControl * avoid sending empty Iwant messages
This commit is contained in:
parent
f81a085d0b
commit
9f301964ed
|
@ -247,12 +247,13 @@ proc handleControl(g: GossipSub, peer: PubSubPeer, rpcMsg: RPCMsg) =
|
||||||
g.handlePrune(peer, control.prune)
|
g.handlePrune(peer, control.prune)
|
||||||
|
|
||||||
var respControl: ControlMessage
|
var respControl: ControlMessage
|
||||||
respControl.iwant.add(g.handleIHave(peer, control.ihave))
|
let iwant = g.handleIHave(peer, control.ihave)
|
||||||
|
if iwant.messageIDs.len > 0:
|
||||||
|
respControl.iwant.add(iwant)
|
||||||
respControl.prune.add(g.handleGraft(peer, control.graft))
|
respControl.prune.add(g.handleGraft(peer, control.graft))
|
||||||
let messages = g.handleIWant(peer, control.iwant)
|
let messages = g.handleIWant(peer, control.iwant)
|
||||||
|
|
||||||
if
|
if
|
||||||
respControl.graft.len > 0 or
|
|
||||||
respControl.prune.len > 0 or
|
respControl.prune.len > 0 or
|
||||||
respControl.iwant.len > 0 or
|
respControl.iwant.len > 0 or
|
||||||
messages.len > 0:
|
messages.len > 0:
|
||||||
|
@ -264,12 +265,15 @@ proc handleControl(g: GossipSub, peer: PubSubPeer, rpcMsg: RPCMsg) =
|
||||||
libp2p_pubsub_broadcast_messages.inc(labelValues = [topic])
|
libp2p_pubsub_broadcast_messages.inc(labelValues = [topic])
|
||||||
else:
|
else:
|
||||||
libp2p_pubsub_broadcast_messages.inc(labelValues = ["generic"])
|
libp2p_pubsub_broadcast_messages.inc(labelValues = ["generic"])
|
||||||
|
|
||||||
libp2p_pubsub_broadcast_iwant.inc(respControl.iwant.len.int64)
|
libp2p_pubsub_broadcast_iwant.inc(respControl.iwant.len.int64)
|
||||||
|
|
||||||
for prune in respControl.prune:
|
for prune in respControl.prune:
|
||||||
if g.knownTopics.contains(prune.topicID):
|
if g.knownTopics.contains(prune.topicID):
|
||||||
libp2p_pubsub_broadcast_prune.inc(labelValues = [prune.topicID])
|
libp2p_pubsub_broadcast_prune.inc(labelValues = [prune.topicID])
|
||||||
else:
|
else:
|
||||||
libp2p_pubsub_broadcast_prune.inc(labelValues = ["generic"])
|
libp2p_pubsub_broadcast_prune.inc(labelValues = ["generic"])
|
||||||
|
|
||||||
trace "sending control message", msg = shortLog(respControl), peer
|
trace "sending control message", msg = shortLog(respControl), peer
|
||||||
g.send(
|
g.send(
|
||||||
peer,
|
peer,
|
||||||
|
|
Loading…
Reference in New Issue