Documentation
¶
Index ¶
- Variables
- type Block
- type BuildJob
- type Builder
- type Collection
- type Committer
- type Ensemble
- func (bs *Ensemble) AddBuilder(v Builder) error
- func (bs *Ensemble) AddCommitter(v Committer) error
- func (bs *Ensemble) AddPublisher(v Publisher) error
- func (bs *Ensemble) AddSequencer(v Sequencer) error
- func (bs *Ensemble) AddSigner(v Signer) error
- func (bs *Ensemble) Builder(id seqtypes.BuilderID) Builder
- func (bs *Ensemble) Builders() []seqtypes.BuilderID
- func (bs *Ensemble) Close() error
- func (bs *Ensemble) Committer(id seqtypes.CommitterID) Committer
- func (bs *Ensemble) Committers() []seqtypes.CommitterID
- func (bs *Ensemble) Load(ctx context.Context) (Starter, error)
- func (bs *Ensemble) Publisher(id seqtypes.PublisherID) Publisher
- func (bs *Ensemble) Publishers() []seqtypes.PublisherID
- func (bs *Ensemble) Sequencer(id seqtypes.SequencerID) Sequencer
- func (bs *Ensemble) Sequencers() []seqtypes.SequencerID
- func (bs *Ensemble) Signer(id seqtypes.SignerID) Signer
- func (bs *Ensemble) Signers() []seqtypes.SignerID
- func (bs *Ensemble) Start(ctx context.Context, opts *StartOpts) (*Ensemble, error)
- type JobRegistry
- type Jobs
- type Loader
- type Publisher
- type Sequencer
- type ServiceOpts
- type SignedBlock
- type Signer
- type StartOpts
- type Starter
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyExists = errors.New("entry with same ID already exists")
Functions ¶
This section is empty.
Types ¶
type BuildJob ¶
type BuildJob interface {
ID() seqtypes.BuildJobID
Cancel(ctx context.Context) error
Seal(ctx context.Context) (Block, error)
String() string
Close() // cleans up and unregisters the job
}
BuildJob provides access to the building work of a single protocol block. This may include extra access, such as inclusion of individual txs or block-building steps.
type Builder ¶
type Builder interface {
NewJob(ctx context.Context, opts *seqtypes.BuildOpts) (BuildJob, error)
String() string
ID() seqtypes.BuilderID
io.Closer
}
Builder provides access to block-building work. Different implementations are available, e.g. for local or remote block-building.
type Collection ¶
type Collection interface {
Builder(id seqtypes.BuilderID) Builder
Signer(id seqtypes.SignerID) Signer
Committer(id seqtypes.CommitterID) Committer
Publisher(id seqtypes.PublisherID) Publisher
Sequencer(id seqtypes.SequencerID) Sequencer
}
type Committer ¶
type Committer interface {
String() string
ID() seqtypes.CommitterID
io.Closer
Commit(ctx context.Context, block SignedBlock) error
}
Committer commits to a (signed) block to become canonical. This work is critical: if a block cannot be committed, the block is not safe to continue to work with, as it can be replaced by another block. E.g.: - commit a block to be persisted in the local node. - commit a block to an op-conductor service.
type Ensemble ¶
type Ensemble struct {
// contains filtered or unexported fields
}
Ensemble is a group of active services to sequence blocks with. Services can only be added to an ensemble, the ensemble is meant to run for the full lifetime of the Go service.
func (*Ensemble) AddBuilder ¶
AddBuilder adds a builder. Errors if the builder already exists.
func (*Ensemble) AddCommitter ¶
AddCommitter adds a committer. Errors if the committer already exists.
func (*Ensemble) AddPublisher ¶
AddPublisher adds a publisher. Errors if the publisher already exists.
func (*Ensemble) AddSequencer ¶
AddSequencer adds a sequencer. Errors if the sequencer already exists.
func (*Ensemble) Committer ¶
func (bs *Ensemble) Committer(id seqtypes.CommitterID) Committer
Committer gets a committer. Nil is returned if the ID is unknown.
func (*Ensemble) Committers ¶
func (bs *Ensemble) Committers() []seqtypes.CommitterID
func (*Ensemble) Load ¶
Load is a short-cut to skip the config phase, and use an existing group of builders.
func (*Ensemble) Publisher ¶
func (bs *Ensemble) Publisher(id seqtypes.PublisherID) Publisher
Publisher gets a publisher. Nil is returned if the ID is unknown.
func (*Ensemble) Publishers ¶
func (bs *Ensemble) Publishers() []seqtypes.PublisherID
func (*Ensemble) Sequencer ¶
func (bs *Ensemble) Sequencer(id seqtypes.SequencerID) Sequencer
Sequencer gets a sequencer. Nil is returned if the ID is unknown.
func (*Ensemble) Sequencers ¶
func (bs *Ensemble) Sequencers() []seqtypes.SequencerID
type JobRegistry ¶
type JobRegistry struct {
// contains filtered or unexported fields
}
func NewJobRegistry ¶
func NewJobRegistry() *JobRegistry
func (*JobRegistry) Clear ¶
func (ba *JobRegistry) Clear()
func (*JobRegistry) GetJob ¶
func (ba *JobRegistry) GetJob(id seqtypes.BuildJobID) BuildJob
GetJob returns nil if the job isn't known.
func (*JobRegistry) Len ¶
func (ba *JobRegistry) Len() int
func (*JobRegistry) RegisterJob ¶
func (ba *JobRegistry) RegisterJob(job BuildJob) error
func (*JobRegistry) UnregisterJob ¶
func (ba *JobRegistry) UnregisterJob(id seqtypes.BuildJobID)
type Jobs ¶
type Jobs interface {
// RegisterJob registers the given block-building job.
// It may return an error if there already exists a job with the same ID.
RegisterJob(job BuildJob) error
// GetJob returns nil if the job isn't known.
GetJob(id seqtypes.BuildJobID) BuildJob
// UnregisterJob removes the block-building job from the tracker.
UnregisterJob(id seqtypes.BuildJobID)
// Clear unregisters all jobs
Clear()
// Len returns the number of registered jobs
Len() int
}
Jobs tracks block-building jobs by ID, so the jobs can be inspected and updated.
type Publisher ¶
type Publisher interface {
String() string
ID() seqtypes.PublisherID
io.Closer
Publish(ctx context.Context, block SignedBlock) error
}
Publisher publishes a (signed) block to external actors. Publishing may fail. E.g. publish the block to node(s) for propagation via P2P.
type Sequencer ¶
type Sequencer interface {
String() string
ID() seqtypes.SequencerID
// Close the sequencer. After closing successfully the sequencer is no longer usable.
Close() error
// Open starts a next sequencing slot
Open(ctx context.Context) error
// BuildJob identifies the current block-building work.
// This work may be interacted with through the block-building API.
// This may returns nil if there is no active job.
BuildJob() BuildJob
// Seal seals the current ongoing block-building job.
// Returns an error if there was no block-building job open.
Seal(ctx context.Context) error
// Prebuilt inserts a pre-built block, skipping block-building.
Prebuilt(ctx context.Context, block Block) error
// Sign the previously built block.
// Returns seqtypes.ErrAlreadySigned if already signed.
// Returns an error if the block could not be signed.
Sign(ctx context.Context) error
// Commit the previously signed block, this ensures we can persist it before relying on it as canonical block.
// Returns seqtypes.ErrAlreadyCommitted if already committed.
// Returns an error if the block failed to commit.
Commit(ctx context.Context) error
// Publish the previously committed block.
// Publishing is not respected by next steps.
// For harder guarantees, use Commit to ensure the payload is successfully shared before the next phase.
// Re-publishing is allowed.
// Returns an error if none was previously successfully committed.
// Returns an error if publishing fails.
Publish(ctx context.Context) error
// Next continues to the next sequencing slot.
// If the current slot is unfinished, then it will finish the current slot.
// If the current slot is fresh, it will be built.
// An error is returned if any step fails. It is safe to re-attempt with Next if so.
Next(ctx context.Context) error
// Start starts automatic sequencing, on top of the given chain head.
// An error is returned if the head of the chain does not match the provided head,
// as safety measure to prevent reorgs during sequencer rotations.
// An seqtypes.ErrSequencerAlreadyActive error is returned if the sequencer has already been started.
Start(ctx context.Context, head common.Hash) error
// Stop stops automatic sequencing, and returns the block-hash of the last sequenced block.
// An seqtypes.ErrSequencerInactive error is returned if the sequencer has already been stopped.
Stop(ctx context.Context) (last common.Hash, err error)
// Active returns true if the automatic sequencing (see Start and Stop) is actively running.
Active() bool
}
Sequencer utilizes Builder, Committer, Signer, Publisher to perform all the responsibilities to extend the chain. A Sequencer may internally pipeline work, but does not expose parallel work like a builder does.
type ServiceOpts ¶
type ServiceOpts struct {
*StartOpts
Services Collection
}
type SignedBlock ¶
type SignedBlock interface {
Block
opsigner.SignedObject
}