diff --git a/go.mod b/go.mod index 66fa8674957c75bf01503e82534a3a0ad7535cc7..0603fe1f1c247730931477452e5fcd71895dc1ac 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 9ae9fa75fa834949a9a2fc145f7e63778e064db2..7062a79e08929ca3a7f89efb94002c6e8c0425e0 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 480f000fa19ad8b5768fd65e5f11fd8a0e4eb52d..def94985660e13a285569442ae8aed15dd8ca6d0 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 {