Giter Site home page Giter Site logo

p2p-decentralized-network's Introduction

P2P decentralized network

Twenty nodes peer-to-peer decentralized network

Installation

This assignment requires you to have Python 3.7 and Docker installed on your system. If you don't already have both, please follow the instructions below:

Project setup

This codebase uses Poetry to manage the Python environment and dependencies. Poetry can be installed on most systems with the following command:

curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python

After cloning this repo, you can use Poetry to install the dependencies:

poetry install

Getting started

We have provided you with a basic template to help you get started on this assignment. This template contains a skeleton Python project, as well as a Docker Compose configuration used to bootstrap a network.

Important: Although it's encouraged, you are not required to use the provided starter code or Docker. Feel free to start from scratch if you don't find it useful.

p2pnetClient

The p2pnetClient class is a stub implementation of the client interface for a node. It should be able to make network calls to a p2pnetServer.

A p2pnetClient instance is initialized with the address of a node.

p2pnetServer

The p2pnetServer class is a stub implementation of a node's server. It should be able to respond to network calls made by a p2pnetClient.

Commands

We have provided you with a simple CLI to test your solution.

start-network

The start-network command spins up a network of 16 nodes using Docker Compose. Each node runs inside its own Docker container and is exposed at a unique port number ranging from 7001-7016.

Each node is initialized with the addresses of two other peers in the network. This creates a simple network topology, but you are encouraged to find more optimal structures.

Docker will automatically build the latest version of your code, so this command can be used to test your solution as you build it.

Example usage:

poetry run p2pnet start-network

stop-network

The stop-network command stops any nodes currently running in the test network.

Example usage:

poetry run p2pnet stop-network

send-message

The send-message command can be used to send a message to a node in the network. This command should only be used after the network has been started with start-network.

Arguments:

  • node-number: The node number to connect to. Must be between 1-16.
  • message: The message to send. Must be a single phrase with no spaces.

Example usage:

# Send the message "apple" to node 4
poetry run p2pnet send-message 4 apple

get-messages

The get-messages command returns all messages that have been received by a single node.

Arguments:

  • node-number: The node number to connect to. Must be between 1-16.

Example usage:

# Get all messages received by node 8
poetry run p2pnet get-messages 8

Example output:
    - Apple (Node 1 -> Node 8 -> Node 10)
    - Banana (Node 3 -> Node 5 -> Node 10)
    - Orange (Node 7 -> Node 15 -> Node 9 -> Node 10)

remove-node

The remove-node command stops a single node in the network.

Arguments:

  • node-number: The node number to remove. Must be between 1-16.

Example usage:

# Stop node 9
poetry run p2pnet remove-node 9

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.