Documentation ¶
Index ¶
- Variables
- type BalanceCall
- type BatchCallContextFn
- type BatchElementCreator
- type BoundContract
- type Call
- 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) GetBytes(i int) []byte
- func (c *CallResult) GetBytes32(i int) [32]byte
- func (c *CallResult) GetBytes32Slice(i int) [][32]byte
- 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
- func (c *ContractCall) CallMethod() string
- func (c *ContractCall) CreateResult() interface{}
- func (c *ContractCall) HandleResult(result interface{}) (*CallResult, error)
- func (c *ContractCall) Pack() ([]byte, error)
- func (c *ContractCall) ToBatchElemCreator() (BatchElementCreator, error)
- func (c *ContractCall) ToCallArgs() (interface{}, error)
- func (c *ContractCall) ToTxCandidate() (txmgr.TxCandidate, error)
- func (c *ContractCall) Unpack(hex hexutil.Bytes) (*CallResult, error)
- type EthRpc
- type IterativeBatchCall
- type MultiCaller
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnknownMethod = errors.New("unknown method") ErrInvalidCall = errors.New("invalid call") )
var DefaultBatchSize = 100
Functions ¶
This section is empty.
Types ¶
type BalanceCall ¶ added in v1.7.2
type BalanceCall struct {
// contains filtered or unexported fields
}
func NewBalanceCall ¶ added in v1.7.2
func NewBalanceCall(addr common.Address) *BalanceCall
func (*BalanceCall) HandleResult ¶ added in v1.7.2
func (b *BalanceCall) HandleResult(result interface{}) (*CallResult, error)
func (*BalanceCall) ToBatchElemCreator ¶ added in v1.7.2
func (b *BalanceCall) ToBatchElemCreator() (BatchElementCreator, error)
type BatchCallContextFn ¶
type BatchElementCreator ¶ added in v1.7.2
type BoundContract ¶
type BoundContract struct {
// contains filtered or unexported fields
}
func NewBoundContract ¶
func NewBoundContract(abi *abi.ABI, addr common.Address) *BoundContract
func (*BoundContract) Addr ¶ added in v1.7.2
func (b *BoundContract) Addr() common.Address
func (*BoundContract) Call ¶
func (b *BoundContract) Call(method string, args ...interface{}) *ContractCall
func (*BoundContract) DecodeCall ¶ added in v1.5.0
func (b *BoundContract) DecodeCall(data []byte) (string, *CallResult, error)
type Call ¶ added in v1.7.2
type Call interface { ToBatchElemCreator() (BatchElementCreator, error) HandleResult(interface{}) (*CallResult, error) }
type CallContextFn ¶
type CallResult ¶
type CallResult struct {
// contains filtered or unexported fields
}
func ReadArray ¶ added in v1.5.0
func ReadArray(ctx context.Context, caller *MultiCaller, block rpcblock.Block, countCall *ContractCall, getCall func(i *big.Int) *ContractCall) ([]*CallResult, error)
ReadArray uses batch calls to load all entries from an array. countCall is used to retrieve the current array length, then getCall is used to create calls for each element which are sent in a batch call. The returned *CallResult slice, contains a result for each entry in the array, in the same order as in the contract.
func (*CallResult) GetAddress ¶
func (c *CallResult) GetAddress(i int) common.Address
func (*CallResult) GetBool ¶
func (c *CallResult) GetBool(i int) bool
func (*CallResult) GetBytes ¶ added in v1.5.0
func (c *CallResult) GetBytes(i int) []byte
func (*CallResult) GetBytes32 ¶ added in v1.5.0
func (c *CallResult) GetBytes32(i int) [32]byte
func (*CallResult) GetBytes32Slice ¶ added in v1.5.0
func (c *CallResult) GetBytes32Slice(i int) [][32]byte
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 ¶
type ContractCall struct { Abi *abi.ABI Addr common.Address Method string Args []interface{} From common.Address }
func NewContractCall ¶
func (*ContractCall) CallMethod ¶ added in v1.7.2
func (c *ContractCall) CallMethod() string
func (*ContractCall) CreateResult ¶ added in v1.7.2
func (c *ContractCall) CreateResult() interface{}
func (*ContractCall) HandleResult ¶ added in v1.7.2
func (c *ContractCall) HandleResult(result interface{}) (*CallResult, error)
func (*ContractCall) Pack ¶
func (c *ContractCall) Pack() ([]byte, error)
func (*ContractCall) ToBatchElemCreator ¶ added in v1.7.2
func (c *ContractCall) ToBatchElemCreator() (BatchElementCreator, 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) BatchSize ¶ added in v1.5.1
func (m *MultiCaller) BatchSize() int
func (*MultiCaller) Call ¶
func (m *MultiCaller) Call(ctx context.Context, block rpcblock.Block, calls ...Call) ([]*CallResult, error)
func (*MultiCaller) SingleCall ¶
func (m *MultiCaller) SingleCall(ctx context.Context, block rpcblock.Block, call Call) (*CallResult, error)