2022-05-09 13:02:34 +00:00
|
|
|
package state_native
|
2022-01-13 11:23:53 +00:00
|
|
|
|
|
|
|
import (
|
2022-08-16 12:20:13 +00:00
|
|
|
enginev1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
|
|
|
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
|
|
|
"github.com/prysmaticlabs/prysm/v3/runtime/version"
|
2022-01-13 11:23:53 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// LatestExecutionPayloadHeader of the beacon state.
|
2022-06-22 11:08:06 +00:00
|
|
|
func (b *BeaconState) LatestExecutionPayloadHeader() (*enginev1.ExecutionPayloadHeader, error) {
|
2022-05-09 13:02:34 +00:00
|
|
|
if b.version == version.Phase0 || b.version == version.Altair {
|
|
|
|
return nil, errNotSupported("LatestExecutionPayloadHeader", b.version)
|
|
|
|
}
|
|
|
|
|
2022-02-01 00:32:39 +00:00
|
|
|
if b.latestExecutionPayloadHeader == nil {
|
2022-01-13 11:23:53 +00:00
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
b.lock.RLock()
|
|
|
|
defer b.lock.RUnlock()
|
|
|
|
|
2022-02-01 00:32:39 +00:00
|
|
|
return b.latestExecutionPayloadHeaderVal(), nil
|
2022-01-13 11:23:53 +00:00
|
|
|
}
|
|
|
|
|
2022-02-01 00:32:39 +00:00
|
|
|
// latestExecutionPayloadHeaderVal of the beacon state.
|
2022-01-13 11:23:53 +00:00
|
|
|
// This assumes that a lock is already held on BeaconState.
|
2022-06-22 11:08:06 +00:00
|
|
|
func (b *BeaconState) latestExecutionPayloadHeaderVal() *enginev1.ExecutionPayloadHeader {
|
2022-02-01 00:32:39 +00:00
|
|
|
return ethpb.CopyExecutionPayloadHeader(b.latestExecutionPayloadHeader)
|
2022-01-13 11:23:53 +00:00
|
|
|
}
|