From 2e9c9f0b0a10e8ec1f53349c84902a314f4c9296 Mon Sep 17 00:00:00 2001 From: Yusef Napora Date: Tue, 19 May 2020 10:52:57 -0400 Subject: [PATCH] update dependencies and use preset decay fns --- go.mod | 2 +- go.sum | 1 + tag_tracer.go | 21 +++++---------------- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/go.mod b/go.mod index 66fa867..0603fe1 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,7 @@ module github.com/libp2p/go-libp2p-pubsub require ( - github.com/benbjohnson/clock v1.0.0 + github.com/benbjohnson/clock v1.0.1 github.com/gogo/protobuf v1.3.1 github.com/ipfs/go-log v1.0.4 github.com/libp2p/go-libp2p-blankhost v0.1.6 diff --git a/go.sum b/go.sum index 9ae9fa7..7062a79 100644 --- a/go.sum +++ b/go.sum @@ -5,6 +5,7 @@ github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAE github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/benbjohnson/clock v1.0.0/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= +github.com/benbjohnson/clock v1.0.1/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= github.com/btcsuite/btcd v0.0.0-20190213025234-306aecffea32/go.mod h1:DrZx5ec/dmnfpw9KyYoQyYo7d0KEvTkk/5M/vbZjAr8= github.com/btcsuite/btcd v0.0.0-20190523000118-16327141da8c/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI= github.com/btcsuite/btcd v0.0.0-20190824003749-130ea5bddde3/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI= diff --git a/tag_tracer.go b/tag_tracer.go index 480f000..def9498 100644 --- a/tag_tracer.go +++ b/tag_tracer.go @@ -141,22 +141,11 @@ func (t *tagTracer) decayingDeliveryTag(topic string) (connmgr.DecayingTag, erro } name := fmt.Sprintf("pubsub-deliveries:%s", topic) - // decrement tag value by GossipSubConnTagDecayAmount at each decay interval - decayFn := func(value connmgr.DecayingValue) (after int, rm bool) { - v := value.Value - GossipSubConnTagDecayAmount - return v, v <= 0 - } - - // bump up to max of GossipSubConnTagMessageDeliveryCap - bumpFn := func(value connmgr.DecayingValue, delta int) (after int) { - val := value.Value + delta - if val > GossipSubConnTagMessageDeliveryCap { - return GossipSubConnTagMessageDeliveryCap - } - return val - } - - return t.decayer.RegisterDecayingTag(name, GossipSubConnTagDecayInterval, decayFn, bumpFn) + return t.decayer.RegisterDecayingTag( + name, + GossipSubConnTagDecayInterval, + connmgr.DecayFixed(GossipSubConnTagDecayAmount), + connmgr.BumpSumBounded(0, GossipSubConnTagMessageDeliveryCap)) } func (t *tagTracer) bumpDeliveryTag(p peer.ID, topic string) error { -- GitLab