Documentation ¶
Index ¶
- Variables
- type BatchCallContextFn
- type Block
- type BoundContract
- type CallContextFn
- type CallResult
- func (c *CallResult) GetAddress(i int) common.Address
- func (c *CallResult) GetBigInt(i int) *big.Int
- func (c *CallResult) GetBool(i int) bool
- func (c *CallResult) GetHash(i int) common.Hash
- func (c *CallResult) GetStruct(i int, target interface{})
- func (c *CallResult) GetUint32(i int) uint32
- func (c *CallResult) GetUint64(i int) uint64
- func (c *CallResult) GetUint8(i int) uint8
- type ContractCall
- type EthRpc
- type IterativeBatchCall
- type MultiCaller
Constants ¶
This section is empty.
Variables ¶
var ( BlockPending = Block{"pending"} BlockLatest = Block{"latest"} BlockSafe = Block{"safe"} BlockFinalized = Block{"finalized"} )
var DefaultBatchSize = 100
Functions ¶
This section is empty.
Types ¶
type BatchCallContextFn ¶
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
Block represents the block ref value in RPC calls. It can be either a label (e.g. latest), a block number or block hash.
func BlockByHash ¶
BlockByHash references a block by hash. Canonical or non-canonical blocks may be referenced.
func BlockByNumber ¶
BlockByNumber references a canonical block by number.
type BoundContract ¶
type BoundContract struct {
// contains filtered or unexported fields
}
func NewBoundContract ¶
func NewBoundContract(abi *abi.ABI, addr common.Address) *BoundContract
func (*BoundContract) Call ¶
func (b *BoundContract) Call(method string, args ...interface{}) *ContractCall
type CallContextFn ¶
type CallResult ¶
type CallResult struct {
// contains filtered or unexported fields
}
func (*CallResult) GetAddress ¶
func (c *CallResult) GetAddress(i int) common.Address
func (*CallResult) GetBool ¶
func (c *CallResult) GetBool(i int) bool
func (*CallResult) GetStruct ¶
func (c *CallResult) GetStruct(i int, target interface{})
func (*CallResult) GetUint32 ¶
func (c *CallResult) GetUint32(i int) uint32
func (*CallResult) GetUint64 ¶
func (c *CallResult) GetUint64(i int) uint64
func (*CallResult) GetUint8 ¶
func (c *CallResult) GetUint8(i int) uint8
type ContractCall ¶
func NewContractCall ¶
func (*ContractCall) Pack ¶
func (c *ContractCall) Pack() ([]byte, error)
func (*ContractCall) ToCallArgs ¶
func (c *ContractCall) ToCallArgs() (interface{}, error)
func (*ContractCall) ToTxCandidate ¶
func (c *ContractCall) ToTxCandidate() (txmgr.TxCandidate, error)
func (*ContractCall) Unpack ¶
func (c *ContractCall) Unpack(hex hexutil.Bytes) (*CallResult, error)
type IterativeBatchCall ¶
IterativeBatchCall batches many RPC requests with safe and easy parallelization. Request errors are handled and re-tried, and the batch size is configurable. Executing IterativeBatchCall is as simple as calling Fetch repeatedly until it returns io.EOF.
func NewIterativeBatchCall ¶
func NewIterativeBatchCall[K any, V any]( requestsKeys []K, makeRequest func(K) (V, rpc.BatchElem), getBatch BatchCallContextFn, getSingle CallContextFn, batchSize int) *IterativeBatchCall[K, V]
NewIterativeBatchCall constructs a batch call, fetching the values with the given keys, and transforms them into a verified final result.
func (*IterativeBatchCall[K, V]) Complete ¶
func (ibc *IterativeBatchCall[K, V]) Complete() bool
Complete indicates if the batch call is done.
func (*IterativeBatchCall[K, V]) Fetch ¶
func (ibc *IterativeBatchCall[K, V]) Fetch(ctx context.Context) error
Fetch fetches more of the data, and returns io.EOF when all data has been fetched. This method is safe to call concurrently; it will parallelize the fetching work. If no work is available, but the fetching is not done yet, then Fetch will block until the next thing can be fetched, or until the context expires.
func (*IterativeBatchCall[K, V]) Reset ¶
func (ibc *IterativeBatchCall[K, V]) Reset()
Reset will clear the batch call, to start fetching all contents from scratch.
func (*IterativeBatchCall[K, V]) Result ¶
func (ibc *IterativeBatchCall[K, V]) Result() ([]V, error)
Result returns the fetched values, checked and transformed to the final output type, if available. If the check fails, the IterativeBatchCall will Reset itself, to be ready for a re-attempt in fetching new data.
type MultiCaller ¶
type MultiCaller struct {
// contains filtered or unexported fields
}
func NewMultiCaller ¶
func NewMultiCaller(rpc EthRpc, batchSize int) *MultiCaller
func (*MultiCaller) Call ¶
func (m *MultiCaller) Call(ctx context.Context, block Block, calls ...*ContractCall) ([]*CallResult, error)
func (*MultiCaller) SingleCall ¶
func (m *MultiCaller) SingleCall(ctx context.Context, block Block, call *ContractCall) (*CallResult, error)