2021-06-30 15:06:19 +00:00
|
|
|
package v1
|
2019-12-04 19:20:33 +00:00
|
|
|
|
|
|
|
import (
|
2021-04-15 12:17:55 +00:00
|
|
|
"context"
|
2019-12-04 19:20:33 +00:00
|
|
|
|
2021-03-18 23:29:06 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil"
|
2021-09-15 01:18:39 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/config/features"
|
2021-07-29 21:45:17 +00:00
|
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
2019-12-04 19:20:33 +00:00
|
|
|
)
|
|
|
|
|
2021-03-16 18:14:26 +00:00
|
|
|
// computeFieldRoots returns the hash tree root computations of every field in
|
2020-01-22 04:36:12 +00:00
|
|
|
// the beacon state as a list of 32 byte roots.
|
2021-07-29 21:45:17 +00:00
|
|
|
func computeFieldRoots(ctx context.Context, state *ethpb.BeaconState) ([][]byte, error) {
|
2021-09-15 01:18:39 +00:00
|
|
|
if features.Get().EnableSSZCache {
|
2021-11-29 16:30:17 +00:00
|
|
|
return stateutil.CachedHasher.ComputeFieldRootsWithHasherPhase0(ctx, state)
|
2019-12-04 19:20:33 +00:00
|
|
|
}
|
2021-11-29 16:30:17 +00:00
|
|
|
return stateutil.NocachedHasher.ComputeFieldRootsWithHasherPhase0(ctx, state)
|
2020-01-22 04:36:12 +00:00
|
|
|
}
|