Documentation ¶
Index ¶
- Variables
- func ContextWithOptions(ctx context.Context, opts ...ClientOption) context.Context
- func GetParentHeight(height uint64) uint64
- type Client
- type ClientFactory
- type ClientOption
- type ClientOptions
- type ClientParams
- type JsonrpcClientFactoryFn
- type JsonrpcClientParams
- type Params
- type RestapiClientFactoryFn
- type RestapiClientParams
- type Result
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrBlockNotFound = xerrors.New("block not found") ErrNotImplemented = xerrors.New("not implemented") )
Functions ¶
func ContextWithOptions ¶
func ContextWithOptions(ctx context.Context, opts ...ClientOption) context.Context
func GetParentHeight ¶
Types ¶
type Client ¶
type Client interface { // BatchGetBlockMetadata fetches the BlockMetadata given a block range [from, to). // The implementation should consider the following optimizations whenever possible: // - Query the block header only. // - Use the batch API to reduce the number of network round-trips. // - If batch API is unavailable, it may use goroutines to parallelize the query. BatchGetBlockMetadata(ctx context.Context, tag uint32, from uint64, to uint64) ([]*api.BlockMetadata, error) // GetBlockByHeight fetches the raw block given a block height. // Optionally it may implement blockchain-specific handling using opts. // For example, in ethereum transaction trace may be skipped if WithBestEffort is enabled. GetBlockByHeight(ctx context.Context, tag uint32, height uint64, opts ...ClientOption) (*api.Block, error) // GetBlockByHash fetches the raw block given a block hash and/or height. // For most blockchains, the unique identifier of a block is the hash, and the hash should be used in the query. // If the blockchain uses the height as the unique identifier, or orphaned blocks are skipped, the height may be used in the query. // Optionally it may implement blockchain-specific handling using opts. GetBlockByHash(ctx context.Context, tag uint32, height uint64, hash string, opts ...ClientOption) (*api.Block, error) // GetLatestHeight returns the height of the latest block. GetLatestHeight(ctx context.Context) (uint64, error) // UpgradeBlock upgrades a block to a new tag. // It is used in backfiller when UpgradeFromTag is enabled. // It should return ErrNotImplemented until there is a need for a new tag. UpgradeBlock(ctx context.Context, block *api.Block, newTag uint32) (*api.Block, error) // CanReprocess returns true if the block is retryable during dlq processing. // It should return false unless WithBestEffort is applicable to the blockchain. CanReprocess(tag uint32, height uint64) bool // GetAccountProof returns the account proof for an given account at a target block. // Note that, in req, height is required while blockHash is optional. GetAccountProof(ctx context.Context, req *api.GetVerifiedAccountStateRequest) (*api.GetAccountProofResponse, error) }
func WithInstrumentInterceptor ¶
WithInstrumentInterceptor returns an instrumented client.
type ClientFactory ¶
type ClientFactory interface { Master() Client Slave() Client Validator() Client Consensus() Client }
func NewJsonrpcClientFactory ¶
func NewJsonrpcClientFactory(params JsonrpcClientParams, clientFactory JsonrpcClientFactoryFn) ClientFactory
func NewRestapiClientFactory ¶
func NewRestapiClientFactory(params RestapiClientParams, clientFactory RestapiClientFactoryFn) ClientFactory
type ClientOption ¶
type ClientOption func(options *ClientOptions)
func WithBestEffort ¶
func WithBestEffort() ClientOption
WithBestEffort enables the client to query data in a best-effort manner. It may return partial results when this option is enabled.
type ClientOptions ¶
type ClientOptions struct {
BestEffort bool
}
func OptionsFromContext ¶
func OptionsFromContext(ctx context.Context) *ClientOptions
type ClientParams ¶
type JsonrpcClientFactoryFn ¶
type JsonrpcClientParams ¶
type Params ¶
type Params struct { fx.In fxparams.Params Parser parser.Parser Bitcoin ClientFactory `name:"bitcoin" optional:"true"` Bsc ClientFactory `name:"bsc" optional:"true"` Ethereum ClientFactory `name:"ethereum" optional:"true"` Rosetta ClientFactory `name:"rosetta" optional:"true"` Solana ClientFactory `name:"solana" optional:"true"` Polygon ClientFactory `name:"polygon" optional:"true"` Avacchain ClientFactory `name:"avacchain" optional:"true"` Arbitrum ClientFactory `name:"arbitrum" optional:"true"` Optimism ClientFactory `name:"optimism" optional:"true"` Base ClientFactory `name:"base" optional:"true"` Fantom ClientFactory `name:"fantom" optional:"true"` Aptos ClientFactory `name:"aptos" optional:"true"` EthereumBeacon ClientFactory `name:"ethereum/beacon" optional:"true"` CosmosStaking ClientFactory `name:"cosmos/staking" optional:"true"` CardanoStaking ClientFactory `name:"cardano/staking" optional:"true"` }
type RestapiClientFactoryFn ¶
type RestapiClientParams ¶
Click to show internal directories.
Click to hide internal directories.