Giter Club home page Giter Club logo

p2p-network-simulator's Introduction

P2P Network Simulator

A REST API application to simulate a p2p network with a tree topology. Following are the endpoints to interact with the program using HTTP calls

  1. The first one is where a node can request to join the p2p network. In this step we just assign the node to the best-fitting parent (the node with the most free capacity).
  2. With the second endpoint, the node can communicate to the service that it is leaving the network. In this case, we want to reorder the current node tree (not all the network) to build the solution where the tree has the fewest number of depth levels.
  3. The last endpoint will reflect the status of the network, returning a list of encoded strings.

see more details about the implementation on wiki

How to start

  • Make sure you have installed latest version of docker and docker engine is up and running.
  • Clone the service locally and navigate to project root directory.
  • To run the service, type docker compose up and enter.
  • Make sure service is up and running.
  • Now you can send request to the service at localhost:8080.

API Reference

Join

  POST /join
  • Request body
    {
        "id": 1,
        "capacity": 2,
    }
  • Response
    {
        "message":"successfully joined",
        "error":false,
        "data":1
    }

Leave

  DELETE /leave/1
  • Response
    {
        "message":"successfully left",
        "error":false,
        "data":1
    }

Trace

  GET /trace
  • Response
    {
        "message":"trace received",
        "error":false,
        "data":["1(0/2)"]
    }  

Status Codes

Service returns the following status codes in its API:

Status Code Description
200 OK
201 CREATED
202 ACCEPTED
400 BAD REQUEST
422 UN PROCESSABLE ENTITY

Unit Tests

To see unit test overall coverage and the coverage of each function, run the following commands

    go test -coverprofile unite-test-cover.out ./...
    go tool cover -func unite-test-cover.out

Coding Standards

Followed clean architecture to organize the code.

p2p-network-simulator's People

Contributors

uzama avatar

Watchers

 avatar

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.