2021-11-29 16:30:17 +00:00
|
|
|
package stateutil
|
2021-07-27 15:47:03 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/pkg/errors"
|
2022-08-16 12:20:13 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
|
|
|
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
2021-07-27 15:47:03 +00:00
|
|
|
)
|
|
|
|
|
2021-11-29 16:30:17 +00:00
|
|
|
// Eth1Root computes the HashTreeRoot Merkleization of
|
2021-07-27 15:47:03 +00:00
|
|
|
// a BeaconBlockHeader struct according to the eth2
|
|
|
|
// Simple Serialize specification.
|
2021-11-29 16:30:17 +00:00
|
|
|
func Eth1Root(hasher ssz.HashFn, eth1Data *ethpb.Eth1Data) ([32]byte, error) {
|
2021-07-27 15:47:03 +00:00
|
|
|
if eth1Data == nil {
|
|
|
|
return [32]byte{}, errors.New("nil eth1 data")
|
|
|
|
}
|
2022-02-22 09:27:51 +00:00
|
|
|
return Eth1DataRootWithHasher(hasher, eth1Data)
|
2021-07-27 15:47:03 +00:00
|
|
|
}
|
|
|
|
|
2022-05-09 13:02:34 +00:00
|
|
|
// Eth1DataVotesRoot computes the HashTreeRoot Merkleization of
|
2021-07-27 15:47:03 +00:00
|
|
|
// a list of Eth1Data structs according to the eth2
|
|
|
|
// Simple Serialize specification.
|
2022-05-09 13:02:34 +00:00
|
|
|
func Eth1DataVotesRoot(eth1DataVotes []*ethpb.Eth1Data) ([32]byte, error) {
|
2022-02-22 09:27:51 +00:00
|
|
|
return Eth1DatasRoot(eth1DataVotes)
|
2021-07-27 15:47:03 +00:00
|
|
|
}
|