Plexus
Dependency-free decentralized peer-to-peer network for storage and communication based on the Kademlia distributed hash table.
Contents
Installing
npm install @nephys/plexus --save
Testing
npm run test
This test will create a 50-Node Local Mesh Network and then go through the 4 following steps.
Step | Description |
---|
Item lookup | Testing if nodes can find an item on the network |
Node lookup | Testing if nodes can find another node on the network |
Broadcasting test | Testing if a node can broadcast to the rest of the network |
Non existent item lookup | Testing if nodes dont find non existent data on the network* |
* (The lookup should timemout and fail)
npm run chat
A demo CLI chat client to test communication between nodes.
npm run broadcast
Testing the broadcasting system between 3 node A, B & C where A & B know eachother, B & C know eachother as well and A & C don't know eachother but should be able to communicate regardless.
// Expected output:
[A] b speaking
[C] b speaking
[B] a speaking
[B] c speaking
[C] a speaking
[A] c speaking
Quick Start
Creating a Plexus Node and joining the Mesh Network.
const plexus = require("plexus");
const node = new plexus.Node({host: "127.0.0.1", port: 8080});
node.connect({host: "remote_ip", port: remote_port});
Storage
Storing and retrieving data on the Network.
const item = node.store({key: key, value: value, republish: true});
const lookup = node.find({key: key});
lookup.on("found", (result) => {
console.log(result);
});
lookup.on("timeout", () => {
console.log("FIND request timed out");
});
Communication
Broadcasting to the whole Network.
(WIP, subject to forwarding loops under certain network conditions)
node.broadcast({data: data});
node.on("broadcast", (data) => {
console.log(data);
});
Documentation
Resources
TODO
* (WIP)
Support Me 🤝
If you like the project and want to support me you can do so by donating any amout to one of the following addresses or by using it in your own projects and sharing this repo.
Tank you! ❤️
@Nephys, 2021