Skip to content

Commit 35bd869

Browse files
committed
chore: use github.com/hashicorp/golang-lru/arc/v2
1 parent 5254d6c commit 35bd869

File tree

8 files changed

+25
-19
lines changed

8 files changed

+25
-19
lines changed

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ require (
5353
github.com/hako/durafmt v0.0.0-20200710122514-c0fb7b4da026
5454
github.com/hannahhoward/go-pubsub v0.0.0-20200423002714-8d62886cc36e
5555
github.com/hashicorp/go-multierror v1.1.1
56-
github.com/hashicorp/golang-lru/v2 v2.0.2
56+
github.com/hashicorp/golang-lru/arc/v2 v2.0.7
57+
github.com/hashicorp/golang-lru/v2 v2.0.7
5758
github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c
5859
github.com/ipfs-force-community/metrics v1.0.1-0.20231011024528-8c881d456601
5960
github.com/ipfs-force-community/sophon-auth v1.14.0

go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,10 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
570570
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
571571
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
572572
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
573-
github.com/hashicorp/golang-lru/v2 v2.0.2 h1:Dwmkdr5Nc/oBiXgJS3CDHNhJtIHkuZ3DZF5twqnfBdU=
574-
github.com/hashicorp/golang-lru/v2 v2.0.2/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
573+
github.com/hashicorp/golang-lru/arc/v2 v2.0.7 h1:QxkVTxwColcduO+LP7eJO56r2hFiG8zEbfAAzRv52KQ=
574+
github.com/hashicorp/golang-lru/arc/v2 v2.0.7/go.mod h1:Pe7gBlGdc8clY5LJ0LpJXMt5AmgmWNH1g+oFFVUHOEc=
575+
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
576+
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
575577
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
576578
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
577579
github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c h1:aY2hhxLhjEAbfXOx2nRJxCXezC6CO2V/yN+OCr1srtk=

pkg/chain/store.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"runtime/debug"
1111
"sync"
1212

13-
lru "github.com/hashicorp/golang-lru/v2"
13+
"github.com/hashicorp/golang-lru/arc/v2"
1414
"github.com/ipld/go-car"
1515
carutil "github.com/ipld/go-car/util"
1616
carv2 "github.com/ipld/go-car/v2"
@@ -128,7 +128,7 @@ type Store struct {
128128
reorgCh chan reorg
129129
reorgNotifeeCh chan ReorgNotifee
130130

131-
tsCache *lru.ARCCache[types.TipSetKey, *types.TipSet]
131+
tsCache *arc.ARCCache[types.TipSetKey, *types.TipSet]
132132
}
133133

134134
// NewStore constructs a new default store.
@@ -137,7 +137,7 @@ func NewStore(chainDs repo.Datastore,
137137
genesisCid cid.Cid,
138138
circulatiingSupplyCalculator ICirculatingSupplyCalcualtor,
139139
) *Store {
140-
tsCache, _ := lru.NewARC[types.TipSetKey, *types.TipSet](DefaultTipsetLruCacheSize)
140+
tsCache, _ := arc.NewARC[types.TipSetKey, *types.TipSet](DefaultTipsetLruCacheSize)
141141
store := &Store{
142142
stateAndBlockSource: cbor.NewCborStore(bsstore),
143143
ds: chainDs,

pkg/consensus/block_validator.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
"github.com/Gurpartap/async"
1212
"github.com/hashicorp/go-multierror"
13-
lru "github.com/hashicorp/golang-lru/v2"
13+
"github.com/hashicorp/golang-lru/arc/v2"
1414
"github.com/ipfs/go-cid"
1515
cbor "github.com/ipfs/go-ipld-cbor"
1616
pubsub "github.com/libp2p/go-libp2p-pubsub"
@@ -78,7 +78,7 @@ type BlockValidator struct {
7878
// gasprice for vm
7979
gasPirceSchedule *gas.PricesSchedule
8080
// cache for validate block
81-
validateBlockCache *lru.ARCCache[cid.Cid, struct{}]
81+
validateBlockCache *arc.ARCCache[cid.Cid, struct{}]
8282

8383
Stmgr StateTransformer
8484
}
@@ -97,7 +97,7 @@ func NewBlockValidator(tv TicketValidator,
9797
config *config.NetworkParamsConfig,
9898
gasPirceSchedule *gas.PricesSchedule,
9999
) *BlockValidator {
100-
validateBlockCache, _ := lru.NewARC[cid.Cid, struct{}](2048)
100+
validateBlockCache, _ := arc.NewARC[cid.Cid, struct{}](2048)
101101
return &BlockValidator{
102102
tv: tv,
103103
bstore: bstore,

pkg/events/message_cache.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"sync"
66

7-
lru "github.com/hashicorp/golang-lru/v2"
7+
"github.com/hashicorp/golang-lru/arc/v2"
88
"github.com/ipfs/go-cid"
99

1010
"github.com/filecoin-project/venus/venus-shared/types"
@@ -14,11 +14,11 @@ type messageCache struct {
1414
api IEvent
1515

1616
blockMsgLk sync.Mutex
17-
blockMsgCache *lru.ARCCache[cid.Cid, *types.BlockMessages]
17+
blockMsgCache *arc.ARCCache[cid.Cid, *types.BlockMessages]
1818
}
1919

2020
func newMessageCache(api IEvent) *messageCache {
21-
blsMsgCache, _ := lru.NewARC[cid.Cid, *types.BlockMessages](500)
21+
blsMsgCache, _ := arc.NewARC[cid.Cid, *types.BlockMessages](500)
2222

2323
return &messageCache{
2424
api: api,

pkg/statemanger/state_manger.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"github.com/filecoin-project/venus/venus-shared/actors/builtin/paych"
2828
blockstoreutil "github.com/filecoin-project/venus/venus-shared/blockstore"
2929
"github.com/filecoin-project/venus/venus-shared/types"
30-
lru "github.com/hashicorp/golang-lru/v2"
30+
"github.com/hashicorp/golang-lru/arc/v2"
3131
"github.com/ipfs/go-cid"
3232
logging "github.com/ipfs/go-log/v2"
3333
"go.opencensus.io/trace"
@@ -78,7 +78,7 @@ type Stmgr struct {
7878

7979
// We keep a small cache for calls to ExecutionTrace which helps improve
8080
// performance for node operators like exchanges and block explorers
81-
execTraceCache *lru.ARCCache[types.TipSetKey, tipSetCacheEntry]
81+
execTraceCache *arc.ARCCache[types.TipSetKey, tipSetCacheEntry]
8282
// We need a lock while making the copy as to prevent other callers
8383
// overwrite the cache while making the copy
8484
execTraceCacheLock sync.Mutex
@@ -94,10 +94,10 @@ func NewStateManager(cs *chain.Store,
9494
actorDebugging bool,
9595
) (*Stmgr, error) {
9696
log.Debugf("execTraceCache size: %d", execTraceCacheSize)
97-
var execTraceCache *lru.ARCCache[types.TipSetKey, tipSetCacheEntry]
97+
var execTraceCache *arc.ARCCache[types.TipSetKey, tipSetCacheEntry]
9898
var err error
9999
if execTraceCacheSize > 0 {
100-
execTraceCache, err = lru.NewARC[types.TipSetKey, tipSetCacheEntry](execTraceCacheSize)
100+
execTraceCache, err = arc.NewARC[types.TipSetKey, tipSetCacheEntry](execTraceCacheSize)
101101
if err != nil {
102102
return nil, err
103103
}

venus-devtool/go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ require (
101101
github.com/hashicorp/errwrap v1.1.0 // indirect
102102
github.com/hashicorp/go-multierror v1.1.1 // indirect
103103
github.com/hashicorp/golang-lru v0.6.0 // indirect
104-
github.com/hashicorp/golang-lru/v2 v2.0.5 // indirect
104+
github.com/hashicorp/golang-lru/arc/v2 v2.0.7 // indirect
105+
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
105106
github.com/icza/backscanner v0.0.0-20210726202459-ac2ffc679f94 // indirect
106107
github.com/ipfs/bbloom v0.0.4 // indirect
107108
github.com/ipfs/boxo v0.10.1 // indirect

venus-devtool/go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,10 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
407407
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
408408
github.com/hashicorp/golang-lru v0.6.0 h1:uL2shRDx7RTrOrTCUZEGP/wJUFiUI8QT6E7z5o8jga4=
409409
github.com/hashicorp/golang-lru v0.6.0/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
410-
github.com/hashicorp/golang-lru/v2 v2.0.5 h1:wW7h1TG88eUIJ2i69gaE3uNVtEPIagzhGvHgwfx2Vm4=
411-
github.com/hashicorp/golang-lru/v2 v2.0.5/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
410+
github.com/hashicorp/golang-lru/arc/v2 v2.0.7 h1:QxkVTxwColcduO+LP7eJO56r2hFiG8zEbfAAzRv52KQ=
411+
github.com/hashicorp/golang-lru/arc/v2 v2.0.7/go.mod h1:Pe7gBlGdc8clY5LJ0LpJXMt5AmgmWNH1g+oFFVUHOEc=
412+
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
413+
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
412414
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
413415
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
414416
github.com/huin/goupnp v1.0.0/go.mod h1:n9v9KO1tAxYH82qOn+UTIFQDmx5n1Zxd/ClZDMX7Bnc=

0 commit comments

Comments
 (0)