Documentation
¶
Index ¶
- Constants
- Variables
- type BaseEthereumClienter
- type BlockNumber
- type BlockNumberFinality
- func (b *BlockNumberFinality) BlockNumber(ctx context.Context, requester ethereum.ChainReader) (uint64, error)
- func (b BlockNumberFinality) IsEmpty() bool
- func (b BlockNumberFinality) IsFinalized() bool
- func (b BlockNumberFinality) IsLatest() bool
- func (b BlockNumberFinality) IsSafe() bool
- func (BlockNumberFinality) JSONSchema() *jsonschema.Schema
- func (b *BlockNumberFinality) LessFinalThan(other BlockNumberFinality) bool
- func (b *BlockNumberFinality) String() string
- func (b *BlockNumberFinality) UnmarshalText(data []byte) error
- type DefaultEthClient
- type EthClienter
- type NoopRPCClient
- type RPCClienter
Constants ¶
const ( SafeBlockName = "SafeBlock" FinalizedBlockName = "FinalizedBlock" LatestBlockName = "LatestBlock" PendingBlockName = "PendingBlock" EmptyBlockName = "" )
const ( Safe = BlockNumber(rpc.SafeBlockNumber) Finalized = BlockNumber(rpc.FinalizedBlockNumber) Latest = BlockNumber(rpc.LatestBlockNumber) Pending = BlockNumber(rpc.PendingBlockNumber) Empty = BlockNumber(0) )
Variables ¶
var ( FinalizedBlock = BlockNumberFinality{Block: Finalized} LatestBlock = BlockNumberFinality{Block: Latest} SafeBlock = BlockNumberFinality{Block: Safe} PendingBlock = BlockNumberFinality{Block: Pending} )
Functions ¶
This section is empty.
Types ¶
type BaseEthereumClienter ¶
type BaseEthereumClienter interface {
ethereum.BlockNumberReader
ethereum.ChainIDReader
ethereum.ChainReader
ethereum.ChainStateReader
ethereum.LogFilterer
ethereum.TransactionReader
bind.ContractBackend
}
BaseEthereumClienter defines the methods required to interact with an Ethereum client.
type BlockNumber ¶
type BlockNumber int64
func NewBlockNumber ¶ added in v0.7.0
func NewBlockNumber(s string) (BlockNumber, error)
func (BlockNumber) ApplyOffset ¶ added in v0.7.0
func (b BlockNumber) ApplyOffset(blockNumber uint64, offset int64) uint64
func (BlockNumber) String ¶ added in v0.7.0
func (b BlockNumber) String() string
type BlockNumberFinality ¶
type BlockNumberFinality struct {
Block BlockNumber
Offset int64
}
BlockNumberFinality represents a block finality with an optional offset
func NewBlockNumberFinality ¶
func NewBlockNumberFinality(s string) (BlockNumberFinality, error)
NewBlockNumberFinality creates a new BlockNumberFinality from a string format: <blockName>[/<offset>] e.g: "SafeBlock", "FinalizedBlock/-5", "LatestBlock/+10"
func (*BlockNumberFinality) BlockNumber ¶ added in v0.7.0
func (b *BlockNumberFinality) BlockNumber(ctx context.Context, requester ethereum.ChainReader) (uint64, error)
BlockNumber gets the safe block number from RPC
func (BlockNumberFinality) IsEmpty ¶
func (b BlockNumberFinality) IsEmpty() bool
IsEmpty returns true if b is empty
func (BlockNumberFinality) IsFinalized ¶
func (b BlockNumberFinality) IsFinalized() bool
IsFinalized returns true if b is finalized
func (BlockNumberFinality) IsLatest ¶ added in v0.7.0
func (b BlockNumberFinality) IsLatest() bool
IsLatest returns true if b is latest with non-negative offset
func (BlockNumberFinality) IsSafe ¶
func (b BlockNumberFinality) IsSafe() bool
IsSafe returns true if b is safe
func (BlockNumberFinality) JSONSchema ¶
func (BlockNumberFinality) JSONSchema() *jsonschema.Schema
JSONSchema returns the JSON schema for BlockNumberFinality
func (*BlockNumberFinality) LessFinalThan ¶ added in v0.7.0
func (b *BlockNumberFinality) LessFinalThan(other BlockNumberFinality) bool
LessFinalThan returns true if b is less strict commitment level than other. In case commitment level keywords are the same, it compares the offsets. finalized ≤ safe ≤ latest ≤ pending
func (*BlockNumberFinality) String ¶
func (b *BlockNumberFinality) String() string
String returns the string representation of the BlockNumberFinality
func (*BlockNumberFinality) UnmarshalText ¶
func (b *BlockNumberFinality) UnmarshalText(data []byte) error
UnmarshalText unmarshalls BlockNumberFinality from text.
type DefaultEthClient ¶
type DefaultEthClient struct {
BaseEthereumClienter
RPCClienter
}
DefaultEthClient is the default implementation of EthClienter.
func NewDefaultEthClient ¶
func NewDefaultEthClient(baseClient BaseEthereumClienter, rpcClient RPCClienter) *DefaultEthClient
NewDefaultEthClient creates a new DefaultEthClient.
type EthClienter ¶
type EthClienter interface {
BaseEthereumClienter
RPCClienter
}
EthClienter defines the methods for an Ethereum RPC client.
func DialWithRetry ¶ added in v0.7.0
func DialWithRetry(ctx context.Context, url string, retryHandler commontypes.RetryHandler) (EthClienter, error)
DialWithRetry attempts to connect to an Ethereum client with retries and exponential backoff. It returns an EthClienter on success or an error if all attempts fail.
type NoopRPCClient ¶
type NoopRPCClient struct{}
NoopRPCClient is no operation implementation for the RPCClienter interface