From a2f1d9e4562be7c05ac19bd7d9079a4e73e1f009 Mon Sep 17 00:00:00 2001 From: Andrew Davis <1709934+Savid@users.noreply.github.com> Date: Thu, 24 Aug 2023 15:57:38 +1000 Subject: [PATCH] feat(ttlcache): move back to upstream package --- go.mod | 2 +- go.sum | 6 +++--- pkg/discovery/cache/duplicate.go | 2 +- pkg/discovery/discovery.go | 4 ++-- pkg/mimicry/coordinator/cache/shared.go | 2 +- pkg/mimicry/p2p/execution/event_transaction.go | 3 ++- pkg/mimicry/p2p/execution/execution.go | 3 ++- pkg/sentry/cache/duplicate.go | 2 +- pkg/sentry/ethereum/services/duties.go | 2 +- pkg/sentry/event/beacon/eth/v1/beacon_committee.go | 4 ++-- pkg/sentry/event/beacon/eth/v1/events_attestation.go | 4 ++-- pkg/sentry/event/beacon/eth/v1/events_block.go | 4 ++-- pkg/sentry/event/beacon/eth/v1/events_chain_reorg.go | 4 ++-- .../event/beacon/eth/v1/events_contribution_and_proof.go | 4 ++-- .../event/beacon/eth/v1/events_finalized_checkpoint.go | 4 ++-- pkg/sentry/event/beacon/eth/v1/events_head.go | 4 ++-- pkg/sentry/event/beacon/eth/v1/events_voluntary_exit.go | 4 ++-- pkg/sentry/event/beacon/eth/v2/beacon_block.go | 4 ++-- pkg/server/geoip/maxmind/maxmind.go | 2 +- pkg/server/store/memory/memory.go | 4 ++-- 20 files changed, 35 insertions(+), 33 deletions(-) diff --git a/go.mod b/go.mod index ab70014a..1314fd72 100644 --- a/go.mod +++ b/go.mod @@ -19,6 +19,7 @@ require ( github.com/google/uuid v1.3.0 github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 github.com/huandu/go-sqlbuilder v1.21.0 + github.com/jellydator/ttlcache/v3 v3.1.0 github.com/lib/pq v1.10.9 github.com/libp2p/go-libp2p v0.27.3 github.com/mitchellh/hashstructure/v2 v2.0.2 @@ -26,7 +27,6 @@ require ( github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.16.0 github.com/redis/go-redis/v9 v9.0.4 - github.com/savid/ttlcache/v3 v3.0.2 github.com/sirupsen/logrus v1.9.3 github.com/spf13/cobra v1.7.0 github.com/stretchr/testify v1.8.2 diff --git a/go.sum b/go.sum index d4907e31..4d0965f1 100644 --- a/go.sum +++ b/go.sum @@ -243,6 +243,8 @@ github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= +github.com/jellydator/ttlcache/v3 v3.1.0 h1:0gPFG0IHHP6xyUyXq+JaD8fwkDCqgqwohXNJBcYE71g= +github.com/jellydator/ttlcache/v3 v3.1.0/go.mod h1:hi7MGFdMAwZna5n2tuvh63DvFLzVKySzCVW6+0gA2n4= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -403,8 +405,6 @@ github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6us github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/samcm/go-eth2-client v0.15.12 h1:BB8dGvQAQFL7ol4584AQch41RQrlmw+7u2dR+VOFM2k= github.com/samcm/go-eth2-client v0.15.12/go.mod h1:PLRKnILnr63V3yl2VagBqnhVRFBWc0V+JhQSsXQaSwQ= -github.com/savid/ttlcache/v3 v3.0.2 h1:P7LAHoFNfCjKKJyYcSTFYsNmO+xHaRXTTrLrjb2UJJY= -github.com/savid/ttlcache/v3 v3.0.2/go.mod h1:9OBR4zMFiOT3Vk2aghO8vOhmsdfTFT4orFnQ4cl+VyM= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= @@ -456,7 +456,7 @@ go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= -go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA= +go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= diff --git a/pkg/discovery/cache/duplicate.go b/pkg/discovery/cache/duplicate.go index 04554700..6cf57bfc 100644 --- a/pkg/discovery/cache/duplicate.go +++ b/pkg/discovery/cache/duplicate.go @@ -5,7 +5,7 @@ import ( "time" "github.com/go-co-op/gocron" - "github.com/savid/ttlcache/v3" + "github.com/jellydator/ttlcache/v3" ) type DuplicateCache struct { diff --git a/pkg/discovery/discovery.go b/pkg/discovery/discovery.go index e2ee1a6c..1694cd33 100644 --- a/pkg/discovery/discovery.go +++ b/pkg/discovery/discovery.go @@ -20,8 +20,8 @@ import ( "github.com/ethpandaops/xatu/pkg/proto/xatu" "github.com/go-co-op/gocron" "github.com/google/uuid" + "github.com/jellydator/ttlcache/v3" "github.com/prometheus/client_golang/prometheus/promhttp" - "github.com/savid/ttlcache/v3" "github.com/sirupsen/logrus" ) @@ -219,7 +219,7 @@ func (d *Discovery) handleNewNodeRecord(ctx context.Context, node *enode.Node, s enr := node.String() - item, retrieved := d.duplicateCache.Node.GetOrSet(enr, time.Now(), ttlcache.DefaultTTL) + item, retrieved := d.duplicateCache.Node.GetOrSet(enr, time.Now(), ttlcache.WithTTL[string, time.Time](ttlcache.DefaultTTL)) if retrieved { d.log.WithFields(logrus.Fields{ "enr": enr, diff --git a/pkg/mimicry/coordinator/cache/shared.go b/pkg/mimicry/coordinator/cache/shared.go index a909fdf1..cc8ffc39 100644 --- a/pkg/mimicry/coordinator/cache/shared.go +++ b/pkg/mimicry/coordinator/cache/shared.go @@ -5,7 +5,7 @@ import ( "time" "github.com/go-co-op/gocron" - "github.com/savid/ttlcache/v3" + "github.com/jellydator/ttlcache/v3" ) type SharedCache struct { diff --git a/pkg/mimicry/p2p/execution/event_transaction.go b/pkg/mimicry/p2p/execution/event_transaction.go index 1d75cb93..1de67bf2 100644 --- a/pkg/mimicry/p2p/execution/event_transaction.go +++ b/pkg/mimicry/p2p/execution/event_transaction.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethpandaops/xatu/pkg/proto/xatu" + "github.com/jellydator/ttlcache/v3" "github.com/sirupsen/logrus" "google.golang.org/protobuf/types/known/timestamppb" "google.golang.org/protobuf/types/known/wrapperspb" @@ -133,7 +134,7 @@ func (p *Peer) ExportTransactions(ctx context.Context, items []*TransactionHashI if txs != nil { for _, tx := range txs.PooledTransactionsPacket { - _, retrieved := p.sharedCache.Transaction.GetOrSet(tx.Hash().String(), true, 1*time.Hour) + _, retrieved := p.sharedCache.Transaction.GetOrSet(tx.Hash().String(), true, ttlcache.WithTTL[string, bool](1*time.Hour)) // transaction was just set in shared cache, so we need to handle it if !retrieved { seen := seenMap[tx.Hash()] diff --git a/pkg/mimicry/p2p/execution/execution.go b/pkg/mimicry/p2p/execution/execution.go index 2e63e361..a412129b 100644 --- a/pkg/mimicry/p2p/execution/execution.go +++ b/pkg/mimicry/p2p/execution/execution.go @@ -9,6 +9,7 @@ import ( "sync" "time" + "github.com/jellydator/ttlcache/v3" "github.com/sirupsen/logrus" "github.com/ethereum/go-ethereum/common" @@ -243,7 +244,7 @@ func (p *Peer) Start(ctx context.Context) (<-chan error, error) { if p.handlers.DecoratedEvent != nil && txs != nil { now := time.Now() for _, tx := range *txs { - _, retrieved := p.sharedCache.Transaction.GetOrSet(tx.Hash().String(), true, 1*time.Hour) + _, retrieved := p.sharedCache.Transaction.GetOrSet(tx.Hash().String(), true, ttlcache.WithTTL[string, bool](1*time.Hour)) // transaction was just set in shared cache, so we need to handle it if !retrieved { event, errT := p.handleTransaction(ctx, now, tx) diff --git a/pkg/sentry/cache/duplicate.go b/pkg/sentry/cache/duplicate.go index defee23d..7b25da03 100644 --- a/pkg/sentry/cache/duplicate.go +++ b/pkg/sentry/cache/duplicate.go @@ -3,7 +3,7 @@ package cache import ( "time" - "github.com/savid/ttlcache/v3" + "github.com/jellydator/ttlcache/v3" ) type DuplicateCache struct { diff --git a/pkg/sentry/ethereum/services/duties.go b/pkg/sentry/ethereum/services/duties.go index f7da0421..cf2649fb 100644 --- a/pkg/sentry/ethereum/services/duties.go +++ b/pkg/sentry/ethereum/services/duties.go @@ -11,7 +11,7 @@ import ( backoff "github.com/cenkalti/backoff/v4" "github.com/ethpandaops/beacon/pkg/beacon" "github.com/ethpandaops/ethwallclock" - "github.com/savid/ttlcache/v3" + "github.com/jellydator/ttlcache/v3" "github.com/sirupsen/logrus" ) diff --git a/pkg/sentry/event/beacon/eth/v1/beacon_committee.go b/pkg/sentry/event/beacon/eth/v1/beacon_committee.go index 128f63a7..350a5175 100644 --- a/pkg/sentry/event/beacon/eth/v1/beacon_committee.go +++ b/pkg/sentry/event/beacon/eth/v1/beacon_committee.go @@ -11,7 +11,7 @@ import ( "github.com/ethpandaops/xatu/pkg/proto/xatu" "github.com/ethpandaops/xatu/pkg/sentry/ethereum" "github.com/google/uuid" - ttlcache "github.com/savid/ttlcache/v3" + ttlcache "github.com/jellydator/ttlcache/v3" "github.com/sirupsen/logrus" "google.golang.org/protobuf/types/known/timestamppb" "google.golang.org/protobuf/types/known/wrapperspb" @@ -87,7 +87,7 @@ func (e *BeaconCommittee) ShouldIgnore(ctx context.Context) (bool, error) { key := fmt.Sprintf("%d-%d-%d", e.epoch, e.event.Index, e.event.Slot) - item, retrieved := e.duplicateCache.GetOrSet(key, e.now, ttlcache.DefaultTTL) + item, retrieved := e.duplicateCache.GetOrSet(key, e.now, ttlcache.WithTTL[string, time.Time](ttlcache.DefaultTTL)) if retrieved { e.log.WithFields(logrus.Fields{ "epoch": e.epoch, diff --git a/pkg/sentry/event/beacon/eth/v1/events_attestation.go b/pkg/sentry/event/beacon/eth/v1/events_attestation.go index bb6dd52b..a098fab6 100644 --- a/pkg/sentry/event/beacon/eth/v1/events_attestation.go +++ b/pkg/sentry/event/beacon/eth/v1/events_attestation.go @@ -10,8 +10,8 @@ import ( "github.com/ethpandaops/xatu/pkg/proto/xatu" "github.com/ethpandaops/xatu/pkg/sentry/ethereum" "github.com/google/uuid" + ttlcache "github.com/jellydator/ttlcache/v3" hashstructure "github.com/mitchellh/hashstructure/v2" - ttlcache "github.com/savid/ttlcache/v3" "github.com/sirupsen/logrus" "google.golang.org/protobuf/types/known/timestamppb" "google.golang.org/protobuf/types/known/wrapperspb" @@ -94,7 +94,7 @@ func (e *EventsAttestation) ShouldIgnore(ctx context.Context) (bool, error) { return true, err } - item, retrieved := e.duplicateCache.GetOrSet(fmt.Sprint(hash), e.now, ttlcache.DefaultTTL) + item, retrieved := e.duplicateCache.GetOrSet(fmt.Sprint(hash), e.now, ttlcache.WithTTL[string, time.Time](ttlcache.DefaultTTL)) if retrieved { e.log.WithFields(logrus.Fields{ "hash": hash, diff --git a/pkg/sentry/event/beacon/eth/v1/events_block.go b/pkg/sentry/event/beacon/eth/v1/events_block.go index e0d76f4b..2b963e71 100644 --- a/pkg/sentry/event/beacon/eth/v1/events_block.go +++ b/pkg/sentry/event/beacon/eth/v1/events_block.go @@ -10,8 +10,8 @@ import ( "github.com/ethpandaops/xatu/pkg/proto/xatu" "github.com/ethpandaops/xatu/pkg/sentry/ethereum" "github.com/google/uuid" + ttlcache "github.com/jellydator/ttlcache/v3" hashstructure "github.com/mitchellh/hashstructure/v2" - ttlcache "github.com/savid/ttlcache/v3" "github.com/sirupsen/logrus" "google.golang.org/protobuf/types/known/timestamppb" "google.golang.org/protobuf/types/known/wrapperspb" @@ -82,7 +82,7 @@ func (e *EventsBlock) ShouldIgnore(ctx context.Context) (bool, error) { return true, err } - item, retrieved := e.duplicateCache.GetOrSet(fmt.Sprint(hash), e.now, ttlcache.DefaultTTL) + item, retrieved := e.duplicateCache.GetOrSet(fmt.Sprint(hash), e.now, ttlcache.WithTTL[string, time.Time](ttlcache.DefaultTTL)) if retrieved { e.log.WithFields(logrus.Fields{ "hash": hash, diff --git a/pkg/sentry/event/beacon/eth/v1/events_chain_reorg.go b/pkg/sentry/event/beacon/eth/v1/events_chain_reorg.go index a6a61d80..94806d29 100644 --- a/pkg/sentry/event/beacon/eth/v1/events_chain_reorg.go +++ b/pkg/sentry/event/beacon/eth/v1/events_chain_reorg.go @@ -10,8 +10,8 @@ import ( "github.com/ethpandaops/xatu/pkg/proto/xatu" "github.com/ethpandaops/xatu/pkg/sentry/ethereum" "github.com/google/uuid" + ttlcache "github.com/jellydator/ttlcache/v3" hashstructure "github.com/mitchellh/hashstructure/v2" - ttlcache "github.com/savid/ttlcache/v3" "github.com/sirupsen/logrus" "google.golang.org/protobuf/types/known/timestamppb" "google.golang.org/protobuf/types/known/wrapperspb" @@ -78,7 +78,7 @@ func (e *EventsChainReorg) ShouldIgnore(ctx context.Context) (bool, error) { return true, err } - item, retrieved := e.duplicateCache.GetOrSet(fmt.Sprint(hash), e.now, ttlcache.DefaultTTL) + item, retrieved := e.duplicateCache.GetOrSet(fmt.Sprint(hash), e.now, ttlcache.WithTTL[string, time.Time](ttlcache.DefaultTTL)) if retrieved { e.log.WithFields(logrus.Fields{ "hash": hash, diff --git a/pkg/sentry/event/beacon/eth/v1/events_contribution_and_proof.go b/pkg/sentry/event/beacon/eth/v1/events_contribution_and_proof.go index 68bed166..08fbb621 100644 --- a/pkg/sentry/event/beacon/eth/v1/events_contribution_and_proof.go +++ b/pkg/sentry/event/beacon/eth/v1/events_contribution_and_proof.go @@ -10,8 +10,8 @@ import ( "github.com/ethpandaops/xatu/pkg/proto/xatu" "github.com/ethpandaops/xatu/pkg/sentry/ethereum" "github.com/google/uuid" + ttlcache "github.com/jellydator/ttlcache/v3" hashstructure "github.com/mitchellh/hashstructure/v2" - ttlcache "github.com/savid/ttlcache/v3" "github.com/sirupsen/logrus" "google.golang.org/protobuf/types/known/timestamppb" "google.golang.org/protobuf/types/known/wrapperspb" @@ -91,7 +91,7 @@ func (e *EventsContributionAndProof) ShouldIgnore(ctx context.Context) (bool, er return true, err } - item, retrieved := e.duplicateCache.GetOrSet(fmt.Sprint(hash), e.now, ttlcache.DefaultTTL) + item, retrieved := e.duplicateCache.GetOrSet(fmt.Sprint(hash), e.now, ttlcache.WithTTL[string, time.Time](ttlcache.DefaultTTL)) if retrieved { e.log.WithFields(logrus.Fields{ "hash": hash, diff --git a/pkg/sentry/event/beacon/eth/v1/events_finalized_checkpoint.go b/pkg/sentry/event/beacon/eth/v1/events_finalized_checkpoint.go index af0aa734..cf47d8d6 100644 --- a/pkg/sentry/event/beacon/eth/v1/events_finalized_checkpoint.go +++ b/pkg/sentry/event/beacon/eth/v1/events_finalized_checkpoint.go @@ -10,8 +10,8 @@ import ( "github.com/ethpandaops/xatu/pkg/proto/xatu" "github.com/ethpandaops/xatu/pkg/sentry/ethereum" "github.com/google/uuid" + ttlcache "github.com/jellydator/ttlcache/v3" hashstructure "github.com/mitchellh/hashstructure/v2" - ttlcache "github.com/savid/ttlcache/v3" "github.com/sirupsen/logrus" "google.golang.org/protobuf/types/known/timestamppb" "google.golang.org/protobuf/types/known/wrapperspb" @@ -82,7 +82,7 @@ func (e *EventsFinalizedCheckpoint) ShouldIgnore(ctx context.Context) (bool, err return true, err } - item, retrieved := e.duplicateCache.GetOrSet(fmt.Sprint(hash), e.now, ttlcache.DefaultTTL) + item, retrieved := e.duplicateCache.GetOrSet(fmt.Sprint(hash), e.now, ttlcache.WithTTL[string, time.Time](ttlcache.DefaultTTL)) if retrieved { e.log.WithFields(logrus.Fields{ "hash": hash, diff --git a/pkg/sentry/event/beacon/eth/v1/events_head.go b/pkg/sentry/event/beacon/eth/v1/events_head.go index 01276a70..80e9a67b 100644 --- a/pkg/sentry/event/beacon/eth/v1/events_head.go +++ b/pkg/sentry/event/beacon/eth/v1/events_head.go @@ -10,8 +10,8 @@ import ( "github.com/ethpandaops/xatu/pkg/proto/xatu" "github.com/ethpandaops/xatu/pkg/sentry/ethereum" "github.com/google/uuid" + ttlcache "github.com/jellydator/ttlcache/v3" hashstructure "github.com/mitchellh/hashstructure/v2" - ttlcache "github.com/savid/ttlcache/v3" "github.com/sirupsen/logrus" "google.golang.org/protobuf/types/known/timestamppb" "google.golang.org/protobuf/types/known/wrapperspb" @@ -85,7 +85,7 @@ func (e *EventsHead) ShouldIgnore(ctx context.Context) (bool, error) { return true, err } - item, retrieved := e.duplicateCache.GetOrSet(fmt.Sprint(hash), e.now, ttlcache.DefaultTTL) + item, retrieved := e.duplicateCache.GetOrSet(fmt.Sprint(hash), e.now, ttlcache.WithTTL[string, time.Time](ttlcache.DefaultTTL)) if retrieved { e.log.WithFields(logrus.Fields{ "hash": hash, diff --git a/pkg/sentry/event/beacon/eth/v1/events_voluntary_exit.go b/pkg/sentry/event/beacon/eth/v1/events_voluntary_exit.go index 0a71e7aa..9d7f6251 100644 --- a/pkg/sentry/event/beacon/eth/v1/events_voluntary_exit.go +++ b/pkg/sentry/event/beacon/eth/v1/events_voluntary_exit.go @@ -10,8 +10,8 @@ import ( "github.com/ethpandaops/xatu/pkg/proto/xatu" "github.com/ethpandaops/xatu/pkg/sentry/ethereum" "github.com/google/uuid" + ttlcache "github.com/jellydator/ttlcache/v3" hashstructure "github.com/mitchellh/hashstructure/v2" - ttlcache "github.com/savid/ttlcache/v3" "github.com/sirupsen/logrus" "google.golang.org/protobuf/types/known/timestamppb" "google.golang.org/protobuf/types/known/wrapperspb" @@ -85,7 +85,7 @@ func (e *EventsVoluntaryExit) ShouldIgnore(ctx context.Context) (bool, error) { return true, err } - item, retrieved := e.duplicateCache.GetOrSet(fmt.Sprint(hash), e.now, ttlcache.DefaultTTL) + item, retrieved := e.duplicateCache.GetOrSet(fmt.Sprint(hash), e.now, ttlcache.WithTTL[string, time.Time](ttlcache.DefaultTTL)) if retrieved { e.log.WithFields(logrus.Fields{ "hash": hash, diff --git a/pkg/sentry/event/beacon/eth/v2/beacon_block.go b/pkg/sentry/event/beacon/eth/v2/beacon_block.go index 5955bf82..0525ed1a 100644 --- a/pkg/sentry/event/beacon/eth/v2/beacon_block.go +++ b/pkg/sentry/event/beacon/eth/v2/beacon_block.go @@ -14,8 +14,8 @@ import ( "github.com/ethpandaops/xatu/pkg/proto/xatu" "github.com/ethpandaops/xatu/pkg/sentry/ethereum" "github.com/google/uuid" + ttlcache "github.com/jellydator/ttlcache/v3" hashstructure "github.com/mitchellh/hashstructure/v2" - ttlcache "github.com/savid/ttlcache/v3" "github.com/sirupsen/logrus" "google.golang.org/protobuf/types/known/timestamppb" "google.golang.org/protobuf/types/known/wrapperspb" @@ -103,7 +103,7 @@ func (e *BeaconBlock) ShouldIgnore(ctx context.Context) (bool, error) { return true, err } - item, retrieved := e.duplicateCache.GetOrSet(fmt.Sprint(hash), e.now, ttlcache.DefaultTTL) + item, retrieved := e.duplicateCache.GetOrSet(fmt.Sprint(hash), e.now, ttlcache.WithTTL[string, time.Time](ttlcache.DefaultTTL)) if retrieved { e.log.WithFields(logrus.Fields{ "hash": hash, diff --git a/pkg/server/geoip/maxmind/maxmind.go b/pkg/server/geoip/maxmind/maxmind.go index 2f499193..b729723c 100644 --- a/pkg/server/geoip/maxmind/maxmind.go +++ b/pkg/server/geoip/maxmind/maxmind.go @@ -6,7 +6,7 @@ import ( "github.com/ethpandaops/xatu/pkg/server/geoip/lookup" "github.com/ethpandaops/xatu/pkg/server/geoip/maxmind/database" - "github.com/savid/ttlcache/v3" + "github.com/jellydator/ttlcache/v3" "github.com/sirupsen/logrus" ) diff --git a/pkg/server/store/memory/memory.go b/pkg/server/store/memory/memory.go index 9387eece..cfc739c8 100644 --- a/pkg/server/store/memory/memory.go +++ b/pkg/server/store/memory/memory.go @@ -4,7 +4,7 @@ import ( "context" "time" - "github.com/savid/ttlcache/v3" + "github.com/jellydator/ttlcache/v3" "github.com/sirupsen/logrus" ) @@ -58,7 +58,7 @@ func (m *Memory) Get(ctx context.Context, key string) (*string, error) { } func (m *Memory) GetOrSet(ctx context.Context, key, value string, ttl time.Duration) (storedValue *string, retrieved bool, err error) { - item, retrieved := m.client.GetOrSet(key, value, ttl) + item, retrieved := m.client.GetOrSet(key, value, ttlcache.WithTTL[string, string](ttl)) if retrieved { m.metrics.AddGet(1, m.Type(), "hit")