rpc_url
Documentation for eth_defi.rpc_url Python module.
Credential-free RPC diagnostics.
Provider constructors register their endpoints before making requests. This also
protects dependency logs and logged exception chains, without shortening links
to unrelated services. Call register_rpc_url() before using an externally
constructed provider. Registration is process-local and safe across threads.
Functions
|
Display a URL as its hostname and optional non-default port. |
|
Install RPC redaction while preserving an existing log record factory. |
|
Shorten registered RPC URLs in diagnostic text. |
|
Register endpoints whose diagnostic representations must be shortened. |
Classes
Protect handler output, including cached exception text and extra fields. |
- get_url_domain(url)
Display a URL as its hostname and optional non-default port.
Credentials, paths, query parameters and fragments are discarded. Invalid URLs use a fixed placeholder rather than echoing the invalid input.
- register_rpc_url(configuration_line)
Register endpoints whose diagnostic representations must be shortened.
Registration installs logging protection before any provider network reads. Fallback configurations and
mev+endpoints are supported. The original strings remain available to callers for real network requests.- Parameters
configuration_line (str) – A URL or space-separated RPC configuration.
- Returns
None.- Return type
None
- redact_rpc_urls(text)
Shorten registered RPC URLs in diagnostic text.
Other URLs are preserved. Request targets in urllib3-style exception text are also shortened, even when the transport omitted the URL’s scheme.
- class RPCURLFilter
Bases:
logging.FilterProtect handler output, including cached exception text and extra fields.
Initialize a filter.
Initialize with the name of the logger which, together with its children, will have its events allowed through the filter. If no name is specified, allow every event.
- filter(record)
Sanitise a record immediately before formatting.
This complements record creation for records received from queues and fields added with
extraafter the record factory has returned.- Parameters
record (logging.LogRecord) – Record about to be emitted.
- Returns
Always
True.- Return type
- __init__(name='')
Initialize a filter.
Initialize with the name of the logger which, together with its children, will have its events allowed through the filter. If no name is specified, allow every event.
- install_rpc_logging(*, from_environment=False)
Install RPC redaction while preserving an existing log record factory.
Repeated calls are idempotent. Each worker registers its own providers; logging setup can additionally seed endpoints from RPC environment values.
- Parameters
from_environment (bool) – Register
JSON_RPC_*and*_RPC_URLvalues.- Returns
None.- Return type
None