@@ -30,7 +30,7 @@ import (
3030 "github.com/CortexFoundation/robot/backend"
3131 "github.com/CortexFoundation/torrentfs/params"
3232 "github.com/CortexFoundation/torrentfs/types"
33- lru "github.com/hashicorp/golang-lru"
33+ lru "github.com/hashicorp/golang-lru/v2 "
3434 "github.com/ucwong/golang-kv"
3535 "math"
3636 "math/big"
@@ -77,8 +77,8 @@ type Monitor struct {
7777 taskCh chan * types.Block
7878 errCh chan error
7979 //newTaskHook func(*types.Block)
80- blockCache * lru.Cache
81- sizeCache * lru.Cache
80+ blockCache * lru.Cache [ uint64 , string ]
81+ sizeCache * lru.Cache [ string , uint64 ]
8282 ckp * params.TrustedCheckpoint
8383 start mclock.AbsTime
8484
@@ -143,8 +143,8 @@ func New(flag *params.Config, cache, compress, listen bool, callback chan any) (
143143 m .startNumber .Store (0 )
144144
145145 m .terminated .Store (false )
146- m .blockCache , _ = lru .New (delay )
147- m .sizeCache , _ = lru .New (batch )
146+ m .blockCache , _ = lru.New [ uint64 , string ] (delay )
147+ m .sizeCache , _ = lru.New [ string , uint64 ] (batch )
148148 m .listen = listen
149149 m .callback = callback
150150
@@ -380,8 +380,8 @@ func (m *Monitor) rpcBatchBlockByNumber(from, to uint64) (result []*types.Block,
380380}
381381
382382func (m * Monitor ) getRemainingSize (address string ) (uint64 , error ) {
383- if size , suc := m .sizeCache .Get (address ); suc && size .( uint64 ) == 0 {
384- return size .( uint64 ) , nil
383+ if size , suc := m .sizeCache .Get (address ); suc && size == 0 {
384+ return size , nil
385385 }
386386 var remainingSize hexutil.Uint64
387387 rpcUploadMeter .Mark (1 )
0 commit comments