concept-examples/blockchain-pow.rb in bitcoin-ruby-0.0.1 vs concept-examples/blockchain-pow.rb in bitcoin-ruby-0.0.2
- old
+ new
@@ -9,10 +9,10 @@
require 'digest/sha2'
def do_work(data, target, nonce=0)
found = nil
- while !found
+ until found
d = data + [nonce].pack("I")
h = Digest::SHA256.hexdigest( Digest::SHA256.digest( d ) ).to_i(16)
if h <= target
found = [h.to_s(16).rjust(64, '0'), nonce]