prysm-pulse/beacon-chain/cache/active_balance_disabled.go
terence tsao 74df479bd3
Use active balance cache (#9469)
* Use active balance cache

* Feature flag and test

* Gazelle

* Fix fuzz

* Fix test

* Mix in validator count

* Update test to reflect validator count

* Add eth1 data block hash

* Fix assign

* Use eth1 data root

* Update active_balance_test.go

* Remove eth1 data root

* Remove eth1 data usage in tests

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
2021-08-26 14:32:40 +00:00

32 lines
918 B
Go

// +build libfuzzer
package cache
import (
"sync"
lru "github.com/hashicorp/golang-lru"
"github.com/prysmaticlabs/prysm/beacon-chain/state"
)
// FakeBalanceCache is a fake struct with 1 LRU cache for looking up balance by epoch.
type FakeBalanceCache struct {
cache *lru.Cache
lock sync.RWMutex
}
// NewEffectiveBalanceCache creates a new effective balance cache for storing/accessing total balance by epoch.
func NewEffectiveBalanceCache() *FakeBalanceCache {
return &FakeBalanceCache{}
}
// AddTotalEffectiveBalance adds a new total effective balance entry for current balance for state `st` into the cache.
func (c *FakeBalanceCache) AddTotalEffectiveBalance(st state.ReadOnlyBeaconState, balance uint64) error {
return nil
}
// Get returns the current epoch's effective balance for state `st` in cache.
func (c *FakeBalanceCache) Get(st state.ReadOnlyBeaconState) (uint64, error) {
return 0, nil
}