[![Build Status](http://img.shields.io/travis/hat-festival/equestreum.svg?style=flat-square)](https://travis-ci.org/hat-festival/equestreum) [![Coverage Status](http://img.shields.io/coveralls/hat-festival/equestreum.svg?style=flat-square)](https://coveralls.io/r/hat-festival/equestreum) [![Gem Version](http://img.shields.io/gem/v/equestreum.svg?style=flat-square)](https://rubygems.org/gems/equestreum) [![License](http://img.shields.io/:license-mit-blue.svg?style=flat-square)](http://hat-festival.mit-license.org) # Equestreum ## A blockchain for the [Voting Machine](//github.com/hat-festival/voting-machine) We're trying to answer [one of the fundamental questions](//www.quora.com/Would-you-rather-fight-100-duck-sized-horses-or-one-horse-sized-duck), and we'd like to store the votes somewhere secure and stable. Unfortunately we don't have access to anything like that, so we built a blockchain instead Starting with [this excellent tutorial](https://yukimotopress.github.io/programming-blockchains-step-by-step), this is about the simplest implementation of a blockchain that I could come up with ## How do I use it? irb(main):001:0> require 'equestreum' => true irb(main):002:0> chain = Equestreum::Chain.new do |c| irb(main):003:1* c.path = '/tmp/shonky.chain' irb(main):004:1> end => [#] irb(main):005:0> chain.first.data => "genesis block" irb(main):006:0> chain.grow 'store this data' => [#, #] irb(main):007:0> chain.count => 2 irb(main):008:0> chain.verified? => true irb(main):009:0> chain.difficulty => 3 irb(main):010:0> chain.difficulty = 4 => 4 irb(main):011:0> chain.grow 'store some more data at a higher difficulty' => [#, #, #] irb(main):012:0> chain.save => 614 irb(main):013:0> c = Equestreum::Chain.revive => [#, #, #] irb(main):014:0> c.map { |b| b.data } => ["genesis block", "store this data", "store some more data at a higher difficulty"] irb(main):015:0> c[1].data = 'this should be immutable' => "this should be immutable" irb(main):016:0> begin irb(main):017:1> c.verified? irb(main):018:1> rescue Equestreum::EquestreumException => e irb(main):019:1> puts e.text irb(main):020:1> end Block at 1 tampered with => nil irb(main):021:0> ## Should I use it? Fuck no