Skip to content

DSNodeConfig

DSNodeConfig

Configuration object for initializing a DSNode instance.

from language_pipes.distributed_state_network import DSNodeConfig

Class Definition

@dataclass(frozen=True)
class DSNodeConfig:
node_id: str
credential_dir: str
port: int
network_ip: Optional[str]
aes_key: Optional[str]
whitelist_ips: List[str]
bootstrap_nodes: List[Endpoint]
whitelist_node_ids: List[str]

Attributes

  • node_id (str): Unique identifier for the node
  • port (int): Port number for the node to listen on (UDP)
  • credential_dir: (str) directory to store ECDSA credentials (default: “[current_directory]/credentials”)
  • network_ip (str): Network ip address (only required if other nodes will connect to you)
  • aes_key (str): Hexadecimal encoded AES-128 key for network encryption (16 bytes / 32 hex characters)
  • whitelist_ips (List[str]): Optional list of allowed peer IP addresses. If empty, all IPs are allowed.
  • whitelist_node_ids (List[str]): Optional list of allowed peer node IDs. If empty, all node IDs are allowed.
  • bootstrap_nodes (List[Endpoint]): List of initial nodes to connect to when joining the network

Note: If network_ip is not supplied, the node’s public IP address is automatically detected by the bootstrap server during the initial handshake.

Methods

from_dict(data: Dict) -> DSNodeConfig

Creates a DSNodeConfig instance from a dictionary.

Parameters:

  • data (Dict): Dictionary containing configuration parameters

Returns:

  • DSNodeConfig: Configuration instance

Example:

config_dict = {
"node_id": "node1",
"port": 8000,
"bootstrap_nodes": [
{"address": "127.0.0.1", "port": 8001}
]
}
config = DSNodeConfig.from_dict(config_dict)

Example for bootstrap node (first node in network):

config_dict = {
"node_id": "bootstrap",
"port": 8000,
"bootstrap_nodes": [] # Empty for first node
}
config = DSNodeConfig.from_dict(config_dict)