Skip to content

Commit

Permalink
Add ProposerIndex() to VersionedSignedProposal.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdee committed Mar 11, 2024
1 parent 3341a4b commit 79aba77
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions api/versionedsignedproposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,50 @@ func (v *VersionedSignedProposal) Slot() (phase0.Slot, error) {
}
}

// ProposerIndex returns the proposer index of the signed proposal.
func (v *VersionedSignedProposal) ProposerIndex() (phase0.ValidatorIndex, error) {
switch v.Version {
case spec.DataVersionPhase0:
if v.Phase0 == nil ||
v.Phase0.Message == nil {
return 0, ErrDataMissing
}

return v.Phase0.Message.ProposerIndex, nil
case spec.DataVersionAltair:
if v.Altair == nil ||
v.Altair.Message == nil {
return 0, ErrDataMissing
}

return v.Altair.Message.ProposerIndex, nil
case spec.DataVersionBellatrix:
if v.Bellatrix == nil ||
v.Bellatrix.Message == nil {
return 0, ErrDataMissing
}

return v.Bellatrix.Message.ProposerIndex, nil
case spec.DataVersionCapella:
if v.Capella == nil ||
v.Capella.Message == nil {
return 0, ErrDataMissing
}

return v.Capella.Message.ProposerIndex, nil
case spec.DataVersionDeneb:
if v.Deneb == nil ||
v.Deneb.SignedBlock == nil ||
v.Deneb.SignedBlock.Message == nil {
return 0, ErrDataMissing
}

return v.Deneb.SignedBlock.Message.ProposerIndex, nil
default:
return 0, ErrUnsupportedVersion
}
}

// ExecutionBlockHash returns the hash of the execution payload.
func (v *VersionedSignedProposal) ExecutionBlockHash() (phase0.Hash32, error) {
switch v.Version {
Expand Down

0 comments on commit 79aba77

Please sign in to comment.