mirror of
https://github.com/logos-messaging/go-libp2p-pubsub.git
synced 2026-01-02 12:53:09 +00:00
inline decayingDeliveryTag method into addDeliveryTag
This commit is contained in:
parent
b20819d046
commit
2f9a678f2e
@ -119,9 +119,15 @@ func (t *tagTracer) addDeliveryTag(topic string) {
|
||||
return
|
||||
}
|
||||
|
||||
name := fmt.Sprintf("pubsub-deliveries:%s", topic)
|
||||
t.Lock()
|
||||
defer t.Unlock()
|
||||
tag, err := t.decayingDeliveryTag(topic)
|
||||
tag, err := t.decayer.RegisterDecayingTag(
|
||||
name,
|
||||
GossipSubConnTagDecayInterval,
|
||||
connmgr.DecayFixed(GossipSubConnTagDecayAmount),
|
||||
connmgr.BumpSumBounded(0, GossipSubConnTagMessageDeliveryCap))
|
||||
|
||||
if err != nil {
|
||||
log.Warnf("unable to create decaying delivery tag: %s", err)
|
||||
return
|
||||
@ -143,19 +149,6 @@ func (t *tagTracer) removeDeliveryTag(topic string) {
|
||||
delete(t.decaying, topic)
|
||||
}
|
||||
|
||||
func (t *tagTracer) decayingDeliveryTag(topic string) (connmgr.DecayingTag, error) {
|
||||
if t.decayer == nil {
|
||||
return nil, fmt.Errorf("connection manager does not support decaying tags")
|
||||
}
|
||||
name := fmt.Sprintf("pubsub-deliveries:%s", topic)
|
||||
|
||||
return t.decayer.RegisterDecayingTag(
|
||||
name,
|
||||
GossipSubConnTagDecayInterval,
|
||||
connmgr.DecayFixed(GossipSubConnTagDecayAmount),
|
||||
connmgr.BumpSumBounded(0, GossipSubConnTagMessageDeliveryCap))
|
||||
}
|
||||
|
||||
func (t *tagTracer) bumpDeliveryTag(p peer.ID, topic string) error {
|
||||
t.RLock()
|
||||
defer t.RUnlock()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user