mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
d077483577
* v3 import renamings * tidy * fmt * rev * Update beacon-chain/core/epoch/precompute/reward_penalty_test.go * Update beacon-chain/core/helpers/validators_test.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/iface/BUILD.bazel * Update beacon-chain/db/kv/kv.go * Update beacon-chain/db/kv/state.go * Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go * Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go * Update beacon-chain/sync/initial-sync/service.go * fix deps * fix bad replacements * fix bad replacements * change back * gohashtree version * fix deps Co-authored-by: Nishant Das <nishdas93@gmail.com> Co-authored-by: Potuz <potuz@prysmaticlabs.com>
33 lines
638 B
Go
33 lines
638 B
Go
package stategen
|
|
|
|
import (
|
|
"github.com/pkg/errors"
|
|
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
|
)
|
|
|
|
var ErrNotInCache = errors.New("state not found in cache")
|
|
|
|
type CachedGetter interface {
|
|
ByBlockRoot([32]byte) (state.BeaconState, error)
|
|
}
|
|
|
|
type CombinedCache struct {
|
|
getters []CachedGetter
|
|
}
|
|
|
|
func (c CombinedCache) ByBlockRoot(r [32]byte) (state.BeaconState, error) {
|
|
for _, getter := range c.getters {
|
|
st, err := getter.ByBlockRoot(r)
|
|
if err == nil {
|
|
return st, nil
|
|
}
|
|
if errors.Is(err, ErrNotInCache) {
|
|
continue
|
|
}
|
|
return nil, err
|
|
}
|
|
return nil, ErrNotInCache
|
|
}
|
|
|
|
var _ CachedGetter = &CombinedCache{}
|