Giter Site home page Giter Site logo

dcc-p2p-blockchain-chat's Introduction

DCC-P2P-BlockChain-Chat

An implementation of a toy P2P Blockchain distributed protocol node. It essentially keeps a distributed message archive, with "transactions" (message additions) being validated with MD5 hashes, that must be mined for each message. Think mini-bitcoin, but for chatting instead of exchanging fictional currency. Strictly IPv4, because IPv6 is too much work :D.

Extreme level of commenting, because it's a university assignment, so why not.

Building

To build, simply run "make", the Makefile target rules should work for most Linux distributions as well as MacOS, as long as OpenSSL is installed.

NOTE: MUST be compiled with gcc for 64 bit architectures, since we use a few nifty x64 implementation-specific things, such as 128 bit primitive types.

Running

To run the program from the command line, use the following syntax:

./blockchain <initial peer IP> <local IP>

Where initial peer IP is the IPv4 address for a peer that you wish to actively connect to at the beginning of execution. Type in a bogus IP to not connect to anyone and simply listen for connections passively.

Local IP should be the IPv4 address for the interface where the program will be listening for connections, to avoid self-connection attempts. This could have been implemented more elegantly using a STUN protocol, but that would have added significant complexity to the project, so we use this workaround.

Functionalities

When the program is running, the terminal will prompt the user for messages to be added to the currently active archive. If any message typed in is valid, it will be inserted in the archive, and the new archive will be published to all the currently connected peers.

For each connected peer, the implementation creates a log file in the running folder, with format "x.log", where x is the file descriptor ID associated with the peer. This is to avoid the standard output streams (stderr/stdout) from being flooded with information from all the different peers. To observe the communication behavior with any given peer, simply peer into the corresponding log file.

If "exit" is typed into the main terminal, the program exits, to guarantee that the output buffers are all flushed appropriately, which doesn't happen when interrupting with the usual CTRL+C.

dcc-p2p-blockchain-chat's People

Contributors

brenocfg avatar

Stargazers

Christian David Posada avatar CHENG KUN avatar whoami avatar Albert Law avatar

Watchers

James Cloos avatar Hoa Thiên Vũ 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.