distributed-state-network
Distributed State Network (DSN) is a Python framework for distributed applications. Each node sends its state to the other nodes automatically. An application does not send a request for the data.
Basis
DSN is a helper for Language Pipes. It is the default technology for shared state in Language Pipes. Two research documents give the basis of the design.
The Maintenance of Duplicate Databases (Paul R. Johnson, Robert H. Thomas)
Language Pipes needs a distributed database. This document was the first to describe direct mail updates. DSN uses this method.
Epidemic algorithms in replicated databases (extended abstract)
DSN uses a simple form of the gossip protocol from this paper. Each node does a check of the health of its connections every 3 seconds. At each check, the node selects one peer at random and sends an update to that peer. The paper shows that this method gives the best ratio of complexity to benefit. Thus all the nodes become synchronized after a short time. DSN operates on a local network, where the loss of packets is not frequent.
Quick start
1. Create the first node
The most simple DSN network has one node. To create this node, do these steps:
- Import
DSNodeServerandDSNodeConfig. - Set
bootstrap_nodesto an empty list. The first node in a network has no bootstrap node. - Start the node with
DSNodeServer.start(). - Write the data to the state of the node with
update_data().
from distributed_state_network import DSNodeServer, DSNodeConfig
def alert(message: str) -> None:
print(message)
# Start a node
node = DSNodeServer.start(
DSNodeConfig.from_dict({
"node_id": "my_first_node",
"port": 8000,
"bootstrap_nodes": [] # Empty for the first node
}),
alert
)
# Write some data
node.update_data("status", "online")
node.update_data("temperature", "72.5")
How it works
DSN makes a peer-to-peer network. Each node keeps its own state database.
Key concepts:
- Each node owns its state. Only that node can change its state.
- The node sends each change of its state to all the connected nodes automatically.
- A node can read the state of each other node immediately.
- The nodes can encrypt all communication with AES-128-CBC. Each message has a new random IV.
Example: a distributed temperature monitor
This example shows a network of temperature sensors. Each sensor writes its temperature to its own state. The monitor station reads the temperature from each sensor.
Do these steps on each Raspberry Pi that has a sensor:
sensor_node = DSNodeServer.start(
DSNodeConfig.from_dict({
"node_id": f"sensor_{location}",
"port": 8000,
"bootstrap_nodes": [{"address": "coordinator.local", "port": 8000}]
}),
alert
)
# Update the temperature every 60 seconds
while True:
temp = read_temperature_sensor()
sensor_node.update_data("temperature", str(temp))
sensor_node.update_data("timestamp", str(time.time()))
time.sleep(60)
Do this step on the monitor station:
for node_id in monitor.peers():
if node_id.startswith("sensor_"):
temp = monitor.read_data(node_id, "temperature")
print(f"{node_id}: {temp}°F")
Metadata
Release files for distributed-state-network 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| distributed_state_network-1.2.0.tar.gz | 20.7 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| distributed_state_network-1.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 42.3 kB
Release files / distributed_state_network-1.2.0.tar.gz
| Download URL | distributed_state_network-1.2.0.tar.gz |
|---|---|
| Size | 20.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4993e6053fed178a9ab9d8b575abe7c24cc2b0e6c01334201fd6d9981473f4a8
|
|
BLAKE2b-256 checksum How to use checksums |
f1863a961a02de6bcfa39e03627b2942f0ca984c41ec7883f53cb3db3d45800b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 9, 2026.
Transparency logRelease files / distributed_state_network-1.2.0-py3-none-any.whl
| Download URL | distributed_state_network-1.2.0-py3-none-any.whl |
|---|---|
| Size | 21.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9c07e73dda614e0d75412ae18bce6104b54cb27ccc51c04e56e0280ced1c115d
|
|
BLAKE2b-256 checksum How to use checksums |
c88d0ab45d276167995f9d1b4f6f46054d5ef9ea76e8e3c54ecf050030f23d1e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 9, 2026.
Transparency logSecurity for distributed-state-network 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for distributed_state_network-1.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 9, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.