Module utils

Module utils 

Source
Expand description

Utility functions for RPC server operations.

This module provides common utilities needed by the RPC server including:

  • Port discovery and availability checking
  • Socket address parsing with sensible defaults
  • Error handling helpers for JSON-RPC responses
  • Convenience functions for common error types

§Port Management

The module includes functions to find available ports automatically, starting from a preferred port (3000) and searching upward if needed.

§Error Handling

Provides helper functions to create properly formatted JSON-RPC error responses with standard error codes and descriptive messages.

Functions§

find_available_port
Find an available port starting from a base port
get_default_rpc_port
Get default RPC server port (tries 3000 first, then searches)
internal_error
Helper to create internal error responses
invalid_params
Helper to create invalid params error
is_port_available
Check if a port is available on localhost
method_not_found
Helper to create method not found error
parse_socket_addr
Parse a socket address, with sensible defaults
to_rpc_error
Convert error to RPC error format