mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-09 19:21:19 +00:00
15b649d760
* Add metrics * Use it * Use it * Fixed exp time and tests * Update on save too * Expose getters * One epoch purge time * Fixed a timing issue * Clean up * Gazelle * Interface * Prune every epoch * Aggregate twice per slot * Revert attsToBeAggregated * Delete expired atts Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package kv
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/patrickmn/go-cache"
|
|
"github.com/prysmaticlabs/prysm/shared/params"
|
|
)
|
|
|
|
// AttCaches defines the caches used to satisfy attestation pool interface.
|
|
// These caches are KV store for various attestations
|
|
// such are unaggregated, aggregated or attestations within a block.
|
|
type AttCaches struct {
|
|
aggregatedAtt *cache.Cache
|
|
unAggregatedAtt *cache.Cache
|
|
forkchoiceAtt *cache.Cache
|
|
blockAtt *cache.Cache
|
|
}
|
|
|
|
// NewAttCaches initializes a new attestation pool consists of multiple KV store in cache for
|
|
// various kind of attestations.
|
|
func NewAttCaches() *AttCaches {
|
|
secsInEpoch := time.Duration(params.BeaconConfig().SlotsPerEpoch * params.BeaconConfig().SecondsPerSlot)
|
|
|
|
// Create caches with default expiration time of one epoch and which
|
|
// purges expired items every epoch.
|
|
pool := &AttCaches{
|
|
unAggregatedAtt: cache.New(secsInEpoch*time.Second, secsInEpoch*time.Second),
|
|
aggregatedAtt: cache.New(secsInEpoch*time.Second, secsInEpoch*time.Second),
|
|
forkchoiceAtt: cache.New(secsInEpoch*time.Second, secsInEpoch*time.Second),
|
|
blockAtt: cache.New(secsInEpoch*time.Second, secsInEpoch*time.Second),
|
|
}
|
|
|
|
return pool
|
|
}
|