Giter VIP home page Giter VIP logo

nephys / plexus Goto Github PK

View Code? Open in Web Editor NEW
11.0 1.0 3.0 267 KB

Dependency-free decentralized peer-to-peer network for storage and communication based on the Kademlia distributed hash table.

License: MIT License

JavaScript 100.00%
p2p peer-to-peer kademlia kademlia-dht kademlia-like nodejs javascript decentralized dependency-free storage communication database discovery dht distributed-hash-table hash-table distributed-systems distributed network

plexus's Introduction

Plexus

License npm (scoped) node-current (scoped)

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");

//  Node creation
const node = new plexus.Node({host: "127.0.0.1", port: 8080});    //  By default the host and port are 127.0.0.1:8080

//  Join the network
node.connect({host: "remote_ip", port: remote_port});

Storage

Storing and retrieving data on the Network.

//  Storing data
const item = node.store({key: key, value: value, republish: true});   //  If no key is provided it will default to the hash of the value stored

//  Retrieving data
const lookup = node.find({key: key});

//  The item exists on the Network
lookup.on("found", (result) => {
    console.log(result);
});

//  The item doesn't exist anywhere on the Network
lookup.on("timeout", () => {
    console.log("FIND request timed out");
});

Communication

Broadcasting to the whole Network.

(WIP, subject to forwarding loops under certain network conditions)
//  Sendind to the Network
node.broadcast({data: data});

//  Handling incoming Broadcasts
node.on("broadcast", (data) => {
    console.log(data);
});

Documentation

Resources

TODO

  • Implement keep alive (ping contacts to keep the UDP hole open)*
  • Implement Item expiration
  • Implement Item propagation
  • Improve the storage system
  • Clean up code
  • Finish implementing error handling using exceptions
  • Add documentation
  • Make broadcasting faster (master & slave broadcasting nodes?) Complete rework
* (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.

Thank you! โค๏ธ



@Nephys, 2021

plexus's People

Contributors

nephys avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

plexus's Issues

announce and lookup

is an announce and lookup feature in the roadmap? like the bittorrent mainline dht, announce('someString') which will announce to the network and add this node's ip and port under this 'someString' and then other nodes can do lookup('someString') and then find all the nodes(their ip and port) listed under that 'someString'. or is this kind of functionality already implemented right now?

connect to multiple peers in case first peer is not responding

with node.connect({host: "remote_ip", port: remote_port}) we can connect to the network with one other node, if that node goes offline, then it will not connect. would it be possible to use an Array[] and connect to multiple nodes, in case the first node does not work?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.