-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuilder.go
47 lines (37 loc) · 1.32 KB
/
builder.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package http
import (
"fmt"
consensus "github.com/umbracle/go-eth-consensus"
)
type BuilderEndpoint struct {
c *Client
}
func (c *Client) Builder() *BuilderEndpoint {
return &BuilderEndpoint{c: c}
}
func (b *BuilderEndpoint) RegisterValidator(msg []*SignedValidatorRegistration) error {
err := b.c.Post("/eth/v1/builder/validators", msg, nil)
return err
}
type BuilderBid struct {
Header *consensus.ExecutionPayloadHeader `json:"header"`
Value consensus.Uint256 `json:"value" ssz-size:"32"`
Pubkey [48]byte `json:"pubkey" ssz-size:"48"`
}
type SignedBuilderBid struct {
Message *BuilderBid `json:"message"`
Signature [96]byte `json:"signature" ssz-size:"96"`
}
func (b *BuilderEndpoint) GetExecutionPayload(slot uint64, parentHash [32]byte, pubKey [48]byte) (*SignedBuilderBid, error) {
var out *SignedBuilderBid
err := b.c.Get(fmt.Sprintf("/eth/v1/builder/header/%d/0x%x/0x%x", slot, parentHash[:], pubKey[:]), &out)
return out, err
}
func (b *BuilderEndpoint) SubmitBlindedBlock(msg *consensus.SignedBlindedBeaconBlock) (*consensus.ExecutionPayload, error) {
var out *consensus.ExecutionPayload
err := b.c.Post("/eth/v1/builder/blinded_blocks", msg, &out)
return out, err
}
func (b *BuilderEndpoint) Status() (bool, error) {
return b.c.Status("/eth/v1/builder/status")
}