Code Monkey home page Code Monkey logo

p2p's Introduction

Distributed Network Applications II

TalTech magister course ITV0120/ITI0215

Andres Käver (183263IAPM) & Anu Kuusmaa (182912IAPM)

Implementation of simple distributed ledger as ASP.NET Core middleware.

Initial spec for work is/was published here: http://lambda.ee/wiki/Vorgurakendused_2_prax_1_2019_kevad (in estonian).
Also saved as pdf (spec01.pdf) in solution root folder for historical purposes.

Second stage spec is here: http://lambda.ee/wiki/Vorgurakendused_2_prax_2_2019_kevad
Also saved as pdf (spec02.pdf) in solution root folder for historical purposes.

Project is/was developed using JetBrains Rider. Dev environment is based on macOS Mojave.

API Endpoints

All the endpoints are based on GET unlesss marked with POST (for example /ledger/receiveblock)

Misc endpoints
/ledger/log
Get the log entries from this host

Endpoints for p2p discovery

/ledger/addr/?addr=<client ip>&port=<client port>  

parameters: addr=127.0.0.1&port=5001 - incoming host also includes its own public ip/port
response: list of hosts known currently - new hosts get added to db

/ledger/ping  

Used during /ledger/addr request to check, that incoming host public info is correct
response: json object with hosts public key.

Endpoints for distributed ledger

/ledger/info 

get ledger hash and block count

/ledger/blocks?from=<hash>&to=<hash>  

get known blocks in chain from host. from - null for genesis block, to - null for till the end

/ledger/createblock?content=<some content>  

insert new block at the end of the chain - to be synced into ledger

/ledger/singleblock?hash=<block hash>  
/ledger/singleblock?payloadhash=<payload hash>  

Get block either by content or block hash

POST

/ledger/receiveledger

Send full ledger over to another host (part of compare and swap) Actual ledger as json in post body

POST

/ledger/receiveblock/?addr=<client ip>&port=<client port>&hash=<block content hash>  

Actual block content as json in post body

Launching network

Start as many hosts as you like. Command line

>dotnet run WebApp.dll <portno> <settings.json>

portno - port to open for listening settings - json file, containing keys and initially known hosts.

There is script file in /Run folder - run.sh. Launches 10 hosts in osx iterm - every one in separate tab.

Monitoring tool

Monitoring tool is written as separate web application, MonitorWeb.
Allows to monitor p2p/ledger network activity and insert new blocks into ledger.

p2p's People

Contributors

akaver avatar anukaver avatar

Stargazers

 avatar Sine Zhang avatar Flavien MICHALECZEK avatar Daniel avatar

Watchers

James Cloos avatar  avatar  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.