Skip to content

Commit

Permalink
add VersionedSignedBeaconBlock.ExecutionRequests()
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Sep 23, 2024
1 parent b50d9cc commit 824cbc6
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions spec/versionedsignedbeaconblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,32 @@ func (v *VersionedSignedBeaconBlock) BlobKZGCommitments() ([]deneb.KZGCommitment
}
}

// ExecutionRequests returs the execution requests for the block.
func (v *VersionedSignedBeaconBlock) ExecutionRequests() (*electra.ExecutionRequests, error) {
switch v.Version {
case DataVersionPhase0:
return nil, errors.New("phase0 block does not have execution requests")
case DataVersionAltair:
return nil, errors.New("altair block does not have execution requests")
case DataVersionBellatrix:
return nil, errors.New("bellatrix block does not have execution requests")
case DataVersionCapella:
return nil, errors.New("capella block does not have execution requests")
case DataVersionDeneb:
return nil, errors.New("deneb block does not have execution requests")
case DataVersionElectra:
if v.Electra == nil ||
v.Electra.Message == nil ||
v.Electra.Message.Body == nil {
return nil, errors.New("no electra block")
}

return v.Electra.Message.Body.ExecutionRequests, nil
default:
return nil, errors.New("unknown version")
}
}

// String returns a string version of the structure.
func (v *VersionedSignedBeaconBlock) String() string {
switch v.Version {
Expand Down

0 comments on commit 824cbc6

Please sign in to comment.