Skip to content

Blockchain demonstration in Ruby with simple Proof of Work

Notifications You must be signed in to change notification settings

adamnoto/naivechain.rb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Naivechain.rb

Naivechain is a Ruby implementation of Blockchain in ~160 lines.

Blockchain is a distributed peer-to-peer, non-functional$ implementation that can be used in a lot of cases where intermediaries exist. Blockchain attempts to disintermediate the world using publicly transparent chains of block spread over nodes.

This implementation takes inspiration from Naivechain excepts:

  1. It used HTTP for all communication
  2. It has proof of work mechanism albeit very simple
  3. It is written in an object-oriented fashion: Block and Chain class.

$: Non-functional requirement: a requirement specifying the how part of a system, e.g.: how the system will work that is, it will work by involving a Blockchain, Merkle tree, and so on. On the other hand, making a borderless transaction is a functional requirement.

Running

Start the server:

rackup ./server.ru -p 9292

Start the client tool:

ruby client.rb
Blockchain client
Specify the port: 9292
9292> hi there

You may spawn as many server and client instances as you please.

Endpoints

Endpoint Purpose
/peers Listing all peers
/chain Showing the chain, including the blocks
/chain/blocks Showing the blocks in the chain
/peers/register/:port Adding a peer in this node, and vice-versa
/chain/add Convenient endpoint to add a new block with text data
/chain/mine Endpoint for peer-to-peer communications

About

Blockchain demonstration in Ruby with simple Proof of Work

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages