Guest User

Untitled

a guest
Oct 20th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. require 'optparse'
  2. require_relative './proof_of_work'
  3.  
  4. options = {}
  5. OptionParser.new do |opts|
  6. opts.on('--input INPUT', 'Input data') { |v| options[:input] = v }
  7. opts.on('--difficulty DIFFICULTY', 'Difficulty (leading zeroes)') { |v| options[:difficulty] = v }
  8. end.parse!
  9.  
  10. start_time = Time.now
  11.  
  12. hash, nonce = ProofOfWork.hash_with_proof_of_work(options[:input], options[:difficulty])
  13.  
  14. puts
  15. puts "Hashed data: #{options[:input]}"
  16. puts "With difficulty: #{options[:difficulty]}"
  17.  
  18. puts
  19. puts "Found nonce: #{nonce}"
  20. puts "Result: #{hash}"
  21. puts "Time to find nonce: #{Time.now - start_time} s"
Add Comment
Please, Sign In to add comment