2021-11-22 23:56:23 +00:00
|
|
|
package v3
|
|
|
|
|
|
|
|
import (
|
2022-06-22 11:08:06 +00:00
|
|
|
enginev1 "github.com/prysmaticlabs/prysm/proto/engine/v1"
|
2021-11-22 23:56:23 +00:00
|
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
|
|
|
)
|
|
|
|
|
|
|
|
// LatestExecutionPayloadHeader of the beacon state.
|
2022-06-22 11:08:06 +00:00
|
|
|
func (b *BeaconState) LatestExecutionPayloadHeader() (*enginev1.ExecutionPayloadHeader, error) {
|
2021-11-22 23:56:23 +00:00
|
|
|
if !b.hasInnerState() {
|
2022-05-17 09:38:35 +00:00
|
|
|
return nil, ErrNilInnerState
|
2021-11-22 23:56:23 +00:00
|
|
|
}
|
|
|
|
if b.state.LatestExecutionPayloadHeader == nil {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
b.lock.RLock()
|
|
|
|
defer b.lock.RUnlock()
|
|
|
|
|
|
|
|
return b.latestExecutionPayloadHeader(), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// latestExecutionPayloadHeader of the beacon state.
|
|
|
|
// This assumes that a lock is already held on BeaconState.
|
2022-06-22 11:08:06 +00:00
|
|
|
func (b *BeaconState) latestExecutionPayloadHeader() *enginev1.ExecutionPayloadHeader {
|
2021-11-22 23:56:23 +00:00
|
|
|
if !b.hasInnerState() {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return ethpb.CopyExecutionPayloadHeader(b.state.LatestExecutionPayloadHeader)
|
|
|
|
}
|