Documentation ¶
Overview ¶
Package provider is the implementation of the Provider interface. it abstracts connecting to different rollup chains and collecting XMsgs and XReceipts to construct XBlock and deliver them to the calling module.
Index ¶
- type Mock
- func (m *Mock) GetBlock(_ context.Context, chainID uint64, height uint64) (xchain.Block, bool, error)
- func (*Mock) GetEmittedCursor(_ context.Context, srcChainID uint64, destChainID uint64) (xchain.StreamCursor, bool, error)
- func (*Mock) GetSubmittedCursor(_ context.Context, destChain uint64, srcChain uint64) (xchain.StreamCursor, bool, error)
- func (m *Mock) StreamAsync(ctx context.Context, chainID uint64, fromHeight uint64, ...) error
- func (m *Mock) StreamBlocks(ctx context.Context, chainID uint64, fromHeight uint64, ...) error
- type Provider
- func (p *Provider) GetBlock(ctx context.Context, chainID uint64, height uint64) (xchain.Block, bool, error)
- func (p *Provider) GetEmittedCursor(ctx context.Context, sourceChainID uint64, destinationChainID uint64) (xchain.StreamCursor, bool, error)
- func (p *Provider) GetSubmittedCursor(ctx context.Context, destChainID uint64, sourceChainID uint64) (xchain.StreamCursor, bool, error)
- func (p *Provider) StreamAsync(ctx context.Context, chainID uint64, fromHeight uint64, ...) error
- func (p *Provider) StreamBlocks(ctx context.Context, chainID uint64, fromHeight uint64, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mock ¶
type Mock struct {
// contains filtered or unexported fields
}
Mock is a mock implementation of the xchain.Provider interface as well as the relayer.XChainClient.
func (*Mock) GetEmittedCursor ¶
func (*Mock) GetSubmittedCursor ¶
func (*Mock) StreamAsync ¶
func (*Mock) StreamBlocks ¶
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider stores the source chain configuration and the global quit channel.
func New ¶
New instantiates the provider instance which will be ready to accept subscriptions for respective destination XBlocks.
func (*Provider) GetBlock ¶
func (p *Provider) GetBlock(ctx context.Context, chainID uint64, height uint64) (xchain.Block, bool, error)
GetBlock returns the XBlock for the provided chain and height, or false if not available yet (not finalized), or an error.
func (*Provider) GetEmittedCursor ¶
func (p *Provider) GetEmittedCursor(ctx context.Context, sourceChainID uint64, destinationChainID uint64, ) (xchain.StreamCursor, bool, error)
GetEmittedCursor returns the emitted cursor for the destination chain on the source chain, or false if not available, or an error. Calls the source chain portal OutXStreamOffset method.
func (*Provider) GetSubmittedCursor ¶
func (p *Provider) GetSubmittedCursor(ctx context.Context, destChainID uint64, sourceChainID uint64, ) (xchain.StreamCursor, bool, error)
GetSubmittedCursor returns the submitted cursor for the source chain on the destination chain, or false if not available, or an error. Calls the destination chain portal InXStreamOffset method.
func (*Provider) StreamAsync ¶
func (p *Provider) StreamAsync( ctx context.Context, chainID uint64, fromHeight uint64, callback xchain.ProviderCallback, ) error
StreamAsync starts a goroutine that streams xblocks asynchronously forever. It returns immediately. It only returns an error if the chainID in invalid. This is the async version of StreamBlocks. It retries forever (with backoff) on all fetch and callback errors.
func (*Provider) StreamBlocks ¶
func (p *Provider) StreamBlocks( ctx context.Context, chainID uint64, fromHeight uint64, callback xchain.ProviderCallback, ) error
StreamBlocks blocks, streaming all xblocks from the chain as they become available (finalized). It retries forever (with backoff) on all fetch errors. It however returns the first callback error. It returns nil when the context is canceled.