mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-08 10:41:19 +00:00
f75a5a5df8
* New pool * Better namings * Fmt * Gazelle * Merge branch 'master' of https://github.com/prysmaticlabs/prysm into define-pool * Raul's feedback * Raul's feedback * Update to use go-cache * Merge branch 'master' of https://github.com/prysmaticlabs/prysm into define-pool-1 * Update workspace * Update workspace * Update pool to use interface * Move kv init methods * Curd for aggregated * Curd for unaggregated * Gaz * Tests for aggregated * Fixed test * Merge branch 'master' of https://github.com/prysmaticlabs/prysm into curd * Minor fixes * Typoe * pool test * Added deletions as well * Merge branch 'master' of https://github.com/prysmaticlabs/prysm into curd * Update beacon-chain/operations/attestations/kv/aggregated.go * Update beacon-chain/operations/attestations/kv/aggregated.go * Update beacon-chain/operations/attestations/kv/unaggregated_test.go * Update beacon-chain/operations/attestations/kv/kv.go
42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
package kv
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/patrickmn/go-cache"
|
|
"github.com/prysmaticlabs/go-bitfield"
|
|
"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
|
|
attInBlock *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 other epoch.
|
|
pool := &AttCaches{
|
|
unAggregatedAtt: cache.New(secsInEpoch*time.Second, 2*secsInEpoch*time.Second),
|
|
aggregatedAtt: cache.New(secsInEpoch*time.Second, 2*secsInEpoch*time.Second),
|
|
attInBlock: cache.New(secsInEpoch*time.Second, 2*secsInEpoch*time.Second),
|
|
}
|
|
|
|
return pool
|
|
}
|
|
|
|
func aggregated(bits bitfield.Bitlist) bool {
|
|
if bits.Count() > 1 {
|
|
return true
|
|
}
|
|
return false
|
|
}
|