Simple distributed blockchain experiment written in Ruby
Switch branches/tags
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
Gemfile Specifiy ruby version in Gemfile Dec 1, 2018
Gemfile.lock Update rack gem Dec 1, 2018
Procfile Add Procfile Dec 1, 2018 Add an implementation todo to readme Dec 7, 2018
block.rb Use new format in Block#to_s Dec 12, 2018
blockchain.rb Use new format in Block#to_s Dec 12, 2018
main.rb Extract network.rb Dec 1, 2018
network.rb Improve Network#add_node Dec 1, 2018
web.rb Return status 200 Dec 1, 2018


Proof of concept distributed blockchain written in ruby.

Install rubygems

$ bundle

Start the first node

$ bundle exec ruby main.rb
Solved: 000008d0b97a697d303f46c7835ffdad23c78574df158169906aaf873e4906e7 1
Server started at http://localhost:4253
Solved: 00000d6d022947c5aba6308e802052a305eabdc7efb97f7ca275c6ef0e48fd70 2
Solved: 00000c289256068a869fc1a45d9381e609215928179123214c01a031423ff36e 3
Solved: 000000834d2d178965a668660dc5cec6e3a16498d928b899c3f3cbb17ebbca82 4
Node connected: http://localhost:4869
Received: 00000d3e95f7e557ffeefaa849c2c72e516a3971db409e37ebc9880e26eaef51 5

Start additional nodes

$ bundle exec ruby main.rb ANOTHER_NODE_IP
Connecting to node: http://localhost:4253
Downloaded 000008d0b97a697d303f46c7835ffdad23c78574df158169906aaf873e4906e7 1
Downloaded 00000d6d022947c5aba6308e802052a305eabdc7efb97f7ca275c6ef0e48fd70 2
Downloaded 00000c289256068a869fc1a45d9381e609215928179123214c01a031423ff36e 3
Downloaded 000000834d2d178965a668660dc5cec6e3a16498d928b899c3f3cbb17ebbca82 4
Finished downloading the chain
Solved: 00000d3e95f7e557ffeefaa849c2c72e516a3971db409e37ebc9880e26eaef51 5

Implementation TODO

  • Clean up code
  • Don't use global variables: $blockchain, $network, $port
  • Create a rubygem
  • Disable Puma's startup message

Protocol TODO

  • Dump/load blockchain to/from a file when starting/exiting the process
  • Make difficulty dynamic with the hash rate
  • Specify a model for data
  • Share list of connected nodes with other nodes