Skip to main content

A tool to distribute the state of a network device to other devices on the network

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

Distributed State Network

A Python framework for building distributed applications where nodes automatically share state without explicit data requests.

Why DSN?

Traditional distributed systems require constant polling or complex pub/sub mechanisms to share state between nodes. DSN solves this by providing:

  • Automatic state synchronization - Changes propagate instantly across the network
  • No single point of failure - Every node maintains its own state
  • Simple key-value interface - Read any node's data as easily as local variables
  • Complete Security - Triple-layer encryption protects your network

Perfect for building distributed monitoring systems, IoT networks, or any application where multiple machines need to share state efficiently.

Installation

pip install distributed-state-network

Quick Start

1. Create Your First Node

The simplest DSN network is a single node:

from distributed_state_network import DSNodeServer, DSNodeConfig

# Generate a network key (do this once for your entire network)
DSNodeServer.generate_key("network.key")

# Start a node
node = DSNodeServer.start(DSNodeConfig(
    node_id="my_first_node",
    port=8000,
    aes_key_file="network.key",
    bootstrap_nodes=[]  # Empty for the first node
))

# Write some data
node.node.update_data("status", "online")
node.node.update_data("temperature", "72.5")

How It Works

DSN creates a peer-to-peer network where each node maintains its own state database:

Key concepts:

  • Each node owns its state and is the only one who can modify it
  • State changes are automatically broadcast to all connected nodes
  • Any node can read any other node's state instantly
  • All communication is encrypted with AES + ECDSA + HTTPS

API Reference

Node Methods

update_data(key, value) - Update a key in this node's state

node.update_data("sensor_reading", "42.0")

read_data(node_id, key) - Read a value from any node's state

temperature = node.read_data("sensor_node", "temperature")

peers() - List all connected nodes

connected_nodes = node.peers()

Example: Distributed Temperature Monitoring

Create a network of temperature sensors that share readings:

# On each Raspberry Pi with a sensor:
sensor_node = DSNodeServer.start(DSNodeConfig(
    node_id=f"sensor_{location}",
    port=8000,
    aes_key_file="network.key",
    bootstrap_nodes=[{"address": "coordinator.local", "port": 8000}]
))

# Continuously update temperature
while True:
    temp = read_temperature_sensor()
    sensor_node.node.update_data("temperature", str(temp))
    sensor_node.node.update_data("timestamp", str(time.time()))
    time.sleep(60)

On the monitoring station:

for node_id in monitor.node.peers():
    if node_id.startswith("sensor_"):
        temp = monitor.node.read_data(node_id, "temperature")
        print(f"{node_id}: {temp}°F")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

distributed_state_network-0.0.2.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

distributed_state_network-0.0.2-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file distributed_state_network-0.0.2.tar.gz.

File metadata

File hashes

Hashes for distributed_state_network-0.0.2.tar.gz
Algorithm Hash digest
SHA256 4d3ca48bc8900d49507c84eeed1b07f41ecdaed5d137c81dc9b722042eb56bb4
MD5 9d02fb8d08db17ae60b0ed58d62efd92
BLAKE2b-256 ffb9b00efb335724e0807aa057551c3e7eb92cdcf15f5f3e13b6673e98ea0d66

See more details on using hashes here.

Provenance

The following attestation bundles were made for distributed_state_network-0.0.2.tar.gz:

Publisher: publish.yml on erinclemmer/distributed_state_network

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file distributed_state_network-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for distributed_state_network-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6b87b70e7bedb6991e0b9dc8a2b4098642d72d43da4cdd9dd3dc561aaebf5e60
MD5 63c869dc85dc28bcd8582bf1adb289b6
BLAKE2b-256 8595bca0df6cf568fbe9d448cdca068ec36639f6e51ced0f8f729d74bd55966f

See more details on using hashes here.

Provenance

The following attestation bundles were made for distributed_state_network-0.0.2-py3-none-any.whl:

Publisher: publish.yml on erinclemmer/distributed_state_network

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page