Resolver (Class)¶
A resolver for discovering Kaspa RPC node endpoints.
Resolvers help clients find available nodes on a network by querying a list of known resolver URLs. Useful for automatic node discovery and load balancing.
__new__
¶
__new__(urls: Optional[Sequence[str]] = None, tls: Optional[bool] = None) -> Resolver
Create a new resolver.
| PARAMETER | DESCRIPTION |
|---|---|
urls
|
Optional list of resolver URLs. Uses defaults if not provided.
TYPE:
|
tls
|
Use TLS connections (default: False).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Resolver
|
A new Resolver instance.
TYPE:
|
get_node
¶
Get a node descriptor from the resolver (async).
| PARAMETER | DESCRIPTION |
|---|---|
encoding
|
RPC encoding - either a string ("borsh" or "json") or an Encoding enum variant.
TYPE:
|
network_id
|
The network to find a node for.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict
|
Node descriptor with connection details.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
Exception
|
If no node is available or resolution fails. |
get_url
¶
Get a node URL from the resolver (async).
| PARAMETER | DESCRIPTION |
|---|---|
encoding
|
RPC encoding - either a string ("borsh" or "json") or an Encoding enum variant.
TYPE:
|
network_id
|
The network to find a node for.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The node WebSocket URL.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
Exception
|
If no node is available or resolution fails. |
urls
¶
Get the list of resolver URLs.
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
list[str]: The resolver URL list. |