A peer-to-peer (P2P) data relay node built with Rust and libp2p, focusing on maintaining the correct sequence of events across a distributed network.
- P2P communication using libp2p
- Sequence preservation using VLC
- Data synchronization and draining with tombstone mechanism
- JSON-RPC server for easy interaction
- Install Rust and Cargo
- Clone the repository
- Create a
config.toml
file (see Configuration section) - Build and run:
cargo build --release
cargo run --release
Create a config.toml
file:
[network]
p2p_port = 8000
rpc_port = 8001
external_ip = "127.0.0.1"
[node]
private_key = "" # Leave empty to generate a new key
bootstrap_peers = ["/ip4/127.0.0.1/tcp/8000/p2p/PEER_ID"]
curl -X POST -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":["Your data here"],"id":1}' \
http://localhost:8001
curl -X POST -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"drain_data","params":[],"id":1}' \
http://localhost:8001
- Uses VLC to timestamp events
- Stores data in ordered structure (BTreeMap)
- Resolves conflicts based on VLC comparisons
- Propagates tombstones to maintain sequence integrity after draining
Set log level with the RUST_LOG
environment variable:
RUST_LOG=info cargo run --release
Contributions are welcome! Please submit a Pull Request.
This project is open source under the MIT License.