mirror of
https://github.com/logos-messaging/go-libp2p-pubsub.git
synced 2026-01-04 05:43:06 +00:00
protect direct and mesh peers in the connection manager
This commit is contained in:
parent
c0712c6e92
commit
df04b05234
@ -11,16 +11,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// GossipSubConnTagValueDirectPeer is the connection manager tag value to
|
|
||||||
// apply to direct peers. This should be high, as we want to prioritize these
|
|
||||||
// connections above all others.
|
|
||||||
GossipSubConnTagValueDirectPeer = 1000
|
|
||||||
|
|
||||||
// GossipSubConnTagValueMeshPeer is the connection manager tag value to apply to
|
|
||||||
// peers in a topic mesh. If a peer is in the mesh for multiple topics, their
|
|
||||||
// connection will be tagged separately for each.
|
|
||||||
GossipSubConnTagValueMeshPeer = 20
|
|
||||||
|
|
||||||
// GossipSubConnTagBumpMessageDelivery is the amount to add to the connection manager
|
// GossipSubConnTagBumpMessageDelivery is the amount to add to the connection manager
|
||||||
// tag that tracks message deliveries. Each time a peer is the first to deliver a
|
// tag that tracks message deliveries. Each time a peer is the first to deliver a
|
||||||
// message within a topic, we "bump" a tag by this amount, up to a maximum
|
// message within a topic, we "bump" a tag by this amount, up to a maximum
|
||||||
@ -96,18 +86,18 @@ func (t *tagTracer) tagPeerIfDirect(p peer.ID) {
|
|||||||
// tag peer if it is a direct peer
|
// tag peer if it is a direct peer
|
||||||
_, direct := t.direct[p]
|
_, direct := t.direct[p]
|
||||||
if direct {
|
if direct {
|
||||||
t.cmgr.TagPeer(p, "pubsub:direct", GossipSubConnTagValueDirectPeer)
|
t.cmgr.Protect(p, "pubsub:<direct>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *tagTracer) tagMeshPeer(p peer.ID, topic string) {
|
func (t *tagTracer) tagMeshPeer(p peer.ID, topic string) {
|
||||||
tag := topicTag(topic)
|
tag := topicTag(topic)
|
||||||
t.cmgr.TagPeer(p, tag, GossipSubConnTagValueMeshPeer)
|
t.cmgr.Protect(p, tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *tagTracer) untagMeshPeer(p peer.ID, topic string) {
|
func (t *tagTracer) untagMeshPeer(p peer.ID, topic string) {
|
||||||
tag := topicTag(topic)
|
tag := topicTag(topic)
|
||||||
t.cmgr.UntagPeer(p, tag)
|
t.cmgr.Unprotect(p, tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
func topicTag(topic string) string {
|
func topicTag(topic string) string {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user