mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 04:47:18 +00:00
a85bf9305d
26 lines
701 B
Go
26 lines
701 B
Go
package cache
|
|||
|
|||
import (
|
|||
"github.com/prysmaticlabs/prysm/shared/params"
|
|||
"k8s.io/client-go/tools/cache"
|
|||
)
|
|||
|
|||
var (
|
|||
// maxCacheSize is 4x of the epoch length for additional cache padding.
|
|||
// Requests should be only accessing committees within defined epoch length.
|
|||
maxCacheSize = int(4 * params.BeaconConfig().SlotsPerEpoch)
|
|||
)
|
|||
|
|||
// trim the FIFO queue to the maxSize.
|
|||
func trim(queue *cache.FIFO, maxSize int) {
|
|||
for s := len(queue.ListKeys()); s > maxSize; s-- {
|
|||
// #nosec G104 popProcessNoopFunc never returns an error
|
|||
_, _ = queue.Pop(popProcessNoopFunc)
|
|||
}
|
|||
}
|
|||
|
|||
// popProcessNoopFunc is a no-op function that never returns an error.
|
|||
func popProcessNoopFunc(obj interface{}) error {
|
|||
return nil
|
|||
}
|