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 (*Mock) ChainVersionHeight(context.Context, xchain.ChainVersion) (uint64, error)
- func (m *Mock) GetBlock(_ context.Context, req xchain.ProviderRequest) (xchain.Block, bool, error)
- func (*Mock) GetEmittedCursor(_ context.Context, _ xchain.EmitRef, stream xchain.StreamID) (xchain.EmitCursor, bool, error)
- func (*Mock) GetSubmittedCursor(_ context.Context, stream xchain.StreamID) (xchain.SubmitCursor, bool, error)
- func (m *Mock) StreamAsync(ctx context.Context, req xchain.ProviderRequest, ...) error
- func (m *Mock) StreamBlocks(ctx context.Context, req xchain.ProviderRequest, ...) error
- type Provider
- func (p *Provider) ChainVersionHeight(ctx context.Context, chainVer xchain.ChainVersion) (uint64, error)
- func (p *Provider) GetBlock(ctx context.Context, req xchain.ProviderRequest) (xchain.Block, bool, error)
- func (p *Provider) GetEmittedCursor(ctx context.Context, ref xchain.EmitRef, stream xchain.StreamID) (xchain.EmitCursor, bool, error)
- func (p *Provider) GetSubmittedCursor(ctx context.Context, stream xchain.StreamID) (xchain.SubmitCursor, bool, error)
- func (p *Provider) StreamAsync(ctx context.Context, req xchain.ProviderRequest, ...) error
- func (p *Provider) StreamBlocks(ctx context.Context, req xchain.ProviderRequest, ...) 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. It generates deterministic blocks and messages for any chain that is queried. Except for omni consensus chain, we use the real cprovider to fetch blocks.
func (*Mock) ChainVersionHeight ¶
func (*Mock) GetEmittedCursor ¶
func (*Mock) GetSubmittedCursor ¶
func (*Mock) StreamAsync ¶
func (m *Mock) StreamAsync(ctx context.Context, req xchain.ProviderRequest, callback xchain.ProviderCallback) error
func (*Mock) StreamBlocks ¶
func (m *Mock) StreamBlocks(ctx context.Context, req xchain.ProviderRequest, callback xchain.ProviderCallback) error
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider stores the source chain configuration and the global quit channel.
func New ¶
func New(network netconf.Network, rpcClients map[uint64]ethclient.Client, cProvider cchain.Provider) *Provider
New instantiates the provider instance which will be ready to accept subscriptions for respective destination XBlocks.
func (*Provider) ChainVersionHeight ¶
func (p *Provider) ChainVersionHeight(ctx context.Context, chainVer xchain.ChainVersion) (uint64, error)
ChainVersionHeight returns the latest height for the provided chain version.
func (*Provider) GetBlock ¶
func (p *Provider) GetBlock(ctx context.Context, req xchain.ProviderRequest) (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, ref xchain.EmitRef, stream xchain.StreamID, ) (xchain.EmitCursor, 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.
Note that the BlockOffset field is not populated for emit cursors, since it isn't stored on-chain but tracked off-chain.
func (*Provider) GetSubmittedCursor ¶
func (p *Provider) GetSubmittedCursor(ctx context.Context, stream xchain.StreamID, ) (xchain.SubmitCursor, 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, req xchain.ProviderRequest, 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, req xchain.ProviderRequest, 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.