Skip to content

Instantly share code, notes, and snippets.

@worace
Last active January 22, 2016 22:17
Show Gist options
  • Save worace/c553948774ec7a681f06 to your computer and use it in GitHub Desktop.
Save worace/c553948774ec7a681f06 to your computer and use it in GitHub Desktop.
require "hurley"
require "json"
require "digest"
def fetch_info
JSON.parse(Hurley.get("http://git-coin.herokuapp.com/target").body)
end
def mine_coin
info = fetch_info
target = info["target"].hex
parent_hash = info["parent_hash"]
(0..1000000).find do |nonce|
Digest::SHA1.hexdigest(parent_hash + nonce.to_s).hex < target
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment