RPCOperationRecorder

Documentation for eth_defi.provider.rpcdb.RPCOperationRecorder Python class.

class RPCOperationRecorder

Bases: object

Bind a fixed operation label to an existing physical-request accumulator.

Multicall attaches this lightweight recorder to its worker-owned provider for the isolated lane. Regular and isolated recorders share the same locked counters: provider retries and verification requests are counted exactly once, without thread-local context, copied counters or a later merge step. The provider binding is restored by the reader even when a request fails. Pickling retains the label and uses the accumulator’s existing serialisation, which excludes the lock and recreates it inside the receiving process.

Attributes summary

stats

Shared accumulator receiving both physical totals and operation breakdowns.

operation

Fixed attribution label; does not mutate the shared phase's default label.

Methods summary

__init__(stats, operation)

record_call(rpc_provider_domain, api_call[, ...])

Count provider attempts using this recorder's explicit operation label.

record_error(rpc_provider_domain, ...[, count])

Keep provider errors in the shared accumulator's existing breakdown.

stats: eth_defi.provider.rpcdb.RPCRequestStats

Shared accumulator receiving both physical totals and operation breakdowns.

operation: str

Fixed attribution label; does not mutate the shared phase’s default label.

record_call(rpc_provider_domain, api_call, count=1)

Count provider attempts using this recorder’s explicit operation label.

The fallback provider invokes the same interface on an accumulator or a recorder. Delegating once keeps operation rows a partition of physical totals, including unsuccessful attempts and provider-switch verification.

Parameters
  • rpc_provider_domain (str) – Provider hostname with an optional port.

  • api_call (str) – JSON-RPC method, such as eth_call.

  • count (int) – Positive number of physical attempts, default one.

Returns

None; the shared accumulator updates under its existing lock.

Return type

None

record_error(rpc_provider_domain, error_code, error_message, count=1)

Keep provider errors in the shared accumulator’s existing breakdown.

Error keys do not include an operation label. Forwarding them unchanged preserves the persisted schema and avoids counting one failure in both the phase accumulator and a separate lane accumulator.

Parameters
  • rpc_provider_domain (str) – Provider hostname with an optional port.

  • error_code (str) – Normalised RPC/HTTP code or exception class name.

  • error_message (str) – Original provider error text.

  • count (int) – Positive number of matching failures, default one.

Returns

None; the shared error counter advances under its existing lock.

Return type

None

__init__(stats, operation)
Parameters
Return type

None