forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsequencer.go
More file actions
80 lines (63 loc) · 2.26 KB
/
sequencer.go
File metadata and controls
80 lines (63 loc) · 2.26 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package frontend
import (
"context"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum-optimism/optimism/op-test-sequencer/sequencer/backend/work"
"github.com/ethereum-optimism/optimism/op-test-sequencer/sequencer/seqtypes"
)
type SequencerFrontend struct {
Sequencer work.Sequencer
Logger log.Logger
}
func (bf *SequencerFrontend) New(ctx context.Context, opts seqtypes.BuildOpts) error {
bf.Logger.Debug("SequencerFrontend New request", "parent", opts.Parent, "l1_origin", opts.L1Origin)
return toJsonError(bf.Sequencer.New(ctx, opts))
}
func (bf *SequencerFrontend) BuildJob() (seqtypes.BuildJobID, error) {
job := bf.Sequencer.BuildJob()
if job == nil {
return "", toJsonError(seqtypes.ErrUnknownJob)
}
return job.ID(), nil
}
func (bf *SequencerFrontend) Open(ctx context.Context) error {
return toJsonError(bf.Sequencer.Open(ctx))
}
func (bf *SequencerFrontend) Seal(ctx context.Context) error {
return toJsonError(bf.Sequencer.Seal(ctx))
}
func (bf *SequencerFrontend) PrebuiltEnvelope(ctx context.Context, block *eth.ExecutionPayloadEnvelope) error {
return toJsonError(bf.Sequencer.Prebuilt(ctx, block))
}
func (bf *SequencerFrontend) Sign(ctx context.Context) error {
return toJsonError(bf.Sequencer.Sign(ctx))
}
func (bf *SequencerFrontend) Commit(ctx context.Context) error {
return toJsonError(bf.Sequencer.Commit(ctx))
}
func (bf *SequencerFrontend) Publish(ctx context.Context) error {
return toJsonError(bf.Sequencer.Publish(ctx))
}
func (bf *SequencerFrontend) Next(ctx context.Context) error {
return toJsonError(bf.Sequencer.Next(ctx))
}
func (bf *SequencerFrontend) Start(ctx context.Context, head common.Hash) error {
return toJsonError(bf.Sequencer.Start(ctx, head))
}
func (bf *SequencerFrontend) Stop(ctx context.Context) (last common.Hash, err error) {
last, err = bf.Sequencer.Stop(ctx)
if err != nil {
return common.Hash{}, toJsonError(err)
}
return
}
func (bf *SequencerFrontend) IncludeTx(ctx context.Context, tx hexutil.Bytes) error {
job := bf.Sequencer.BuildJob()
if job == nil {
return toJsonError(seqtypes.ErrUnknownJob)
}
return toJsonError(job.IncludeTx(ctx, tx))
}