From 2f9a678f2e85a21204e5870a7481c6901b2ece5f Mon Sep 17 00:00:00 2001 From: Yusef Napora Date: Fri, 15 May 2020 13:46:21 -0400 Subject: [PATCH] inline decayingDeliveryTag method into addDeliveryTag --- tag_tracer.go | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/tag_tracer.go b/tag_tracer.go index 6b57a4f..fa34173 100644 --- a/tag_tracer.go +++ b/tag_tracer.go @@ -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()