2021-11-22 23:56:23 +00:00
|
|
|
package v3
|
|
|
|
|
2022-07-13 01:49:38 +00:00
|
|
|
import (
|
|
|
|
"github.com/pkg/errors"
|
2022-08-16 12:20:13 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
|
|
|
|
enginev1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
2022-07-13 01:49:38 +00:00
|
|
|
)
|
2021-11-22 23:56:23 +00:00
|
|
|
|
|
|
|
// SetLatestExecutionPayloadHeader for the beacon state.
|
2022-07-13 01:49:38 +00:00
|
|
|
func (b *BeaconState) SetLatestExecutionPayloadHeader(val interfaces.ExecutionData) error {
|
2021-11-22 23:56:23 +00:00
|
|
|
if !b.hasInnerState() {
|
|
|
|
return ErrNilInnerState
|
|
|
|
}
|
|
|
|
b.lock.Lock()
|
|
|
|
defer b.lock.Unlock()
|
|
|
|
|
2022-07-13 01:49:38 +00:00
|
|
|
header, ok := val.Proto().(*enginev1.ExecutionPayloadHeader)
|
|
|
|
if !ok {
|
|
|
|
return errors.New("value must be an execution payload header")
|
|
|
|
}
|
|
|
|
b.state.LatestExecutionPayloadHeader = header
|
2021-11-22 23:56:23 +00:00
|
|
|
b.markFieldAsDirty(latestExecutionPayloadHeader)
|
|
|
|
return nil
|
|
|
|
}
|