Skip to content

Commit

Permalink
use versionedExecutionPayload
Browse files Browse the repository at this point in the history
  • Loading branch information
jinmel committed Sep 9, 2024
1 parent df7b346 commit 9396701
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,29 @@ type Builder struct {
stop chan struct{}
}

type VersionedExecutionPayload struct {
Version spec.DataVersion
Bellatrix *bellatrix.ExecutionPayload
Capella *capella.ExecutionPayload
Deneb *deneb.ExecutionPayload
}

type versionJSON struct {
Version spec.DataVersion `json:"version"`
}

type bellatrixVersionedExecutionPayloadJSON struct {
Data *bellatrix.ExecutionPayload `json:"data"`
}

type capellaVersionedExecutionPayloadJSON struct {
Data *capella.ExecutionPayload `json:"data"`
}

type denebVersionedExecutionPayloadJSON struct {
Data *deneb.ExecutionPayload `json:"data"`
}

// BuilderArgs is a struct that contains all the arguments needed to create a new Builder
type BuilderArgs struct {
sk *bls.SecretKey
Expand Down Expand Up @@ -244,9 +267,16 @@ func (b *Builder) handleGetPayload(w http.ResponseWriter, req *http.Request) {
return
}

versionedExecutionPayload := &VersionedExecutionPayload{
Version: bestSubmission.Version,
Bellatrix: bestSubmission.Bellatrix.ExecutionPayload,
Capella: bestSubmission.Capella.ExecutionPayload,
Deneb: bestSubmission.Deneb.ExecutionPayload,
}

w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
if err := json.NewEncoder(w).Encode(bestSubmission); err != nil {
if err := json.NewEncoder(w).Encode(versionedExecutionPayload); err != nil {
updateServeTimeHistogram("getPayload", false, time.Since(start))
log.Error("could not encode response", "err", err)
respondError(w, http.StatusInternalServerError, "could not encode response")
Expand Down

0 comments on commit 9396701

Please sign in to comment.