Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter interface {
// Name returns the unique identifier of the rollup implementation (e.g., "optimism").
Name() string
// Version returns the version string of the rollup implementation.
Version() string
// ChainID returns the blockchain identifier that this rollup instance
// is configured to operate on.
ChainID() string
// HandleXTRequest processes an incoming cross-chain transaction request (XTRequest).
// The 'from' parameter indicates the sender's identifier.
HandleXTRequest(ctx context.Context, from string, req *pb.XTRequest) error
// HandleVote processes an incoming 2PC vote message.
// The 'from' parameter indicates the sender's identifier.
HandleVote(ctx context.Context, from string, vote *pb.Vote) error
// HandleDecision processes an incoming 2PC decision message (commit/abort).
// The 'from' parameter indicates the sender's identifier.
HandleDecision(ctx context.Context, from string, decision *pb.Decided) error
// HandleBlock processes an incoming block submission.
// The 'from' parameter indicates the sender's identifier.
HandleBlock(ctx context.Context, from string, block *pb.Block) error
// OnStart is a lifecycle hook called when the adapter is starting.
// Implementations can use this for initialization logic.
OnStart(ctx context.Context) error
// OnStop is a lifecycle hook called when the adapter is stopping.
// Implementations can use this for cleanup logic.
OnStop(ctx context.Context) error
}
Adapter defines the interface for a rollup-specific implementation that integrates with the shared publisher. It provides methods for identifying the rollup and handling various types of messages received from the publisher.
type BaseAdapter ¶
type BaseAdapter struct {
// contains filtered or unexported fields
}
BaseAdapter provides a default, embeddable implementation of the Adapter interface. It is intended to be used by rollup implementations to reduce boilerplate code.
The BaseAdapter provides no-op implementations for the lifecycle hooks (OnStart, OnStop) and basic getters for identity fields. Rollup-specific logic, especially for message handling, must be implemented by the consuming type that embeds BaseAdapter.
func NewBaseAdapter ¶
func NewBaseAdapter(name, version, chainID string) *BaseAdapter
NewBaseAdapter creates a new instance of BaseAdapter with the provided identity information (name, version, and chain ID).
func (*BaseAdapter) ChainID ¶
func (b *BaseAdapter) ChainID() string
ChainID returns the chain ID that the rollup is configured to operate on.
func (*BaseAdapter) Name ¶
func (b *BaseAdapter) Name() string
Name returns the identifier of the rollup implementation.
func (*BaseAdapter) OnStart ¶
func (b *BaseAdapter) OnStart(ctx context.Context) error
OnStart is a no-op lifecycle hook. It is called when the adapter starts. By default, it returns nil. Implementers can override this method to add custom startup logic for their rollup adapter.
func (*BaseAdapter) OnStop ¶
func (b *BaseAdapter) OnStop(ctx context.Context) error
OnStop is a no-op lifecycle hook. It is called when the adapter stops. By default, it returns nil. Implementers can override this method to add custom shutdown or cleanup logic for their rollup adapter.
func (*BaseAdapter) Version ¶
func (b *BaseAdapter) Version() string
Version returns the version of the rollup implementation.