Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'optparse'
- require_relative './proof_of_work'
- options = {}
- OptionParser.new do |opts|
- opts.on('--input INPUT', 'Input data') { |v| options[:input] = v }
- opts.on('--difficulty DIFFICULTY', 'Difficulty (leading zeroes)') { |v| options[:difficulty] = v }
- end.parse!
- start_time = Time.now
- hash, nonce = ProofOfWork.hash_with_proof_of_work(options[:input], options[:difficulty])
- puts
- puts "Hashed data: #{options[:input]}"
- puts "With difficulty: #{options[:difficulty]}"
- puts
- puts "Found nonce: #{nonce}"
- puts "Result: #{hash}"
- puts "Time to find nonce: #{Time.now - start_time} s"
Add Comment
Please, Sign In to add comment