Documentation
¶
Overview ¶
Package protocolio provides bounded, redacted I/O for protocol adapters.
Index ¶
- Constants
- func Action(s string) error
- func AddressWord(a common.Address) []byte
- func Ancestor(ctx context.Context, r interface{ ... }, witness *types.Header, ...) (*types.Header, error)
- func BlockArgument(number *big.Int) string
- func Bytes(s string, max int) ([]byte, error)
- func CallArgument(msg ethereum.CallMsg) map[string]any
- func CallData(ctx context.Context, r provider.Reader, s provider.Snapshot, to common.Address, ...) ([]byte, error)
- func CallFailure(method string, call ethereum.CallMsg, block *big.Int, err error) error
- func CallHTTPBatch(ctx context.Context, client *http.Client, endpoint string, ...) error
- func Canonical(ctx context.Context, r provider.Reader, s provider.Snapshot) error
- func CheckHeader(header *types.Header, number *big.Int) error
- func Digest(domain, structure common.Hash) common.Hash
- func Domain(name, version string, chainID *big.Int, contract common.Address) common.Hash
- func Execution(ctx context.Context, r provider.Reader, s provider.Snapshot) error
- func Failure(operation string, err error) error
- func Hash(s string) (common.Hash, error)
- func Snapshot(s provider.Snapshot) error
- func Word(n *big.Int) []byte
- type AggregateCall
- type AggregateCodec
- type AggregateResult
- type BatchReader
- type Client
- type HTTPConfig
- type RPCBatchCall
- type RPCBatchReader
- type ReadKind
- type ReadRequest
- type ReadResult
- type ReadResults
Constants ¶
const MaxReadBatch = 256
MaxReadBatch bounds one backend request. ReadGroup chunks larger independent groups.
const StandardMulticall3 = "0xcA11bde05977b3631167028862bE2a173976CA11"
StandardMulticall3 is the official deployment address. A missing or incompatible deployment causes aggregation to fail; hosts must never silently substitute it.
Variables ¶
This section is empty.
Functions ¶
func AddressWord ¶
func Ancestor ¶
func Ancestor(ctx context.Context, r interface { HeaderByHash(context.Context, common.Hash) (*types.Header, error) }, witness *types.Header, number *big.Int) (*types.Header, error)
Ancestor follows parent hashes from witness down to number.
func BlockArgument ¶
BlockArgument preserves exact pinned heights and special block tags.
func CallArgument ¶
CallArgument matches ethclient's complete CallMsg encoding, including zero From, typed transactions and authorizations. Unknown contracts are isolated eth_calls.
func CallData ¶
func CallData(ctx context.Context, r provider.Reader, s provider.Snapshot, to common.Address, data []byte) ([]byte, error)
CallData performs a pinned raw read; callers use generated typed Pack/Unpack methods.
func CallFailure ¶
CallFailure retains public call identity, never arguments, signatures or URLs.
func CallHTTPBatch ¶
func CallHTTPBatch(ctx context.Context, client *http.Client, endpoint string, batch []rpc.BatchElem) error
CallHTTPBatch uses ordinary RPC objects for contract reads and singleton groups. Only groups containing other RPC methods use arrays. The supplied host transport and strict response validation apply to both shapes.
func Canonical ¶
Canonical checks the pinned hash after external I/O and before external mutations. Numeric-block eth_call alone cannot detect an intervening reorganization.
func CheckHeader ¶
CheckHeader requires a uint64-numbered header, at number when one is given.
Types ¶
type AggregateCall ¶
AggregateCall and AggregateResult keep ABI generation in the host codec.
type AggregateCodec ¶
type AggregateCodec interface {
Encode([]AggregateCall) ([]byte, error)
Decode([]byte) ([]AggregateResult, error)
}
type AggregateResult ¶
type BatchReader ¶
type BatchReader interface {
BatchRead(context.Context, []ReadRequest) ([]ReadResult, error)
}
BatchReader is optional. It must return exactly one ordered result per request; member errors stay attached to their member, independently of transport failure. Implementations must not retry an actual failed batch as individual reads.
type HTTPConfig ¶
HTTPConfig bounds one public protocol API. All errors omit URLs, response bodies and headers.
type RPCBatchCall ¶
RPCBatchCall sends one bounded logical group, reporting each member in its Result.
type RPCBatchReader ¶
type RPCBatchReader struct {
Call RPCBatchCall
Multicall common.Address
Codec AggregateCodec
}
RPCBatchReader groups only source-reviewed, caller-independent getters. The host supplies its existing read transport and generated aggregate binding.
func (RPCBatchReader) BatchRead ¶
func (r RPCBatchReader) BatchRead(ctx context.Context, requests []ReadRequest) ([]ReadResult, error)
type ReadRequest ¶
type ReadRequest struct {
Kind ReadKind
Call ethereum.CallMsg
Block *big.Int
Filter ethereum.FilterQuery
Hash common.Hash
MulticallSafe bool
}
ReadRequest describes an independent read. MulticallSafe is an explicit promise that a getter is caller-independent, read-only and unaffected by shared transient state. A backend may aggregate compatible safe calls; other calls retain Call's exact execution context in isolated eth_call requests. Block nil means latest.
func ContractRead ¶
type ReadResult ¶
type ReadResult struct {
Data []byte
Header *types.Header
Logs []types.Log
Receipt *types.Receipt
Err error
}
func (ReadResult) CallData ¶
func (r ReadResult) CallData() ([]byte, error)
CallData preserves the protocol read error boundary for batched member failures.
type ReadResults ¶
type ReadResults struct {
// contains filtered or unexported fields
}
ReadResults is scoped to one sequential read stage, not a cross-block cache. At lazily reads single-call backends, preserving early-return behavior and existing interfaces. Real batches execute once and defer only consumption of member errors. It is intended for use by one goroutine.
func ReadGroup ¶
func ReadGroup(ctx context.Context, reader any, requests ...ReadRequest) (*ReadResults, error)
func (*ReadResults) At ¶
func (g *ReadResults) At(index int) ReadResult