nectarapi.noderpc module
- class nectarapi.noderpc.NodeRPC(*args: Any, **kwargs: Any)
Bases:
GrapheneRPCThis class allows to call API methods exposed by the witness node via websockets / rpc-json.
- Parameters:
urls (str) – Either a single Websocket/Http URL, or a list of URLs
user (str) – Username for Authentication
password (str) – Password for Authentication
num_retries (int) – Try x times to num_retries to a node on disconnect, -1 for indefinitely
num_retries_call (int) – Repeat num_retries_call times a rpc call on node error (default is 5)
timeout (int) – Timeout setting for https nodes (default is 60)
use_tor (bool) – When set to true, ‘socks5h://localhost:9050’ is set as proxy
- get_account(name, **kwargs)
Get full account details from account name
- Parameters:
name (str) – Account name
- rpcexec(payload: Dict[str, Any] | List[Dict[str, Any]]) Any
Execute an RPC call with node-aware retry and Hive-specific error handling.
Sends the given JSON-RPC payload via the underlying GrapheneRPC implementation and handles node-level failures, automatic retries, and node switching when appropriate. If the instance flag next_node_on_empty_reply is set, an empty reply may trigger switching to the next node (when multiple nodes are available). Retries are governed by the node manager’s retry policy.
- Parameters:
payload (dict or list): JSON-RPC payload to send (method, params, id, etc.).
- Raises:
RPCConnection: if no RPC URL is configured (connection not established). CallRetriesReached: when the node-manager’s retry budget is exhausted and no alternative node can be used. RPCError: when the remote node returns an RPC error that is not recoverable by retries/switching. Exception: any other unexpected exception raised by the underlying RPC call is propagated.
- set_next_node_on_empty_reply(next_node_on_empty_reply: bool = True) None
Switch to next node on empty reply for the next rpc call