lib/equestreum/block.rb in equestreum-0.1.1 vs lib/equestreum/block.rb in equestreum-0.1.2
- old
+ new
@@ -11,15 +11,30 @@
def mine
@time = Time.now.to_i
@nonce = 0
loop do
- @hash = Equestreum.hash @nonce, @difficulty, @prev, @data
+ @hash = Equestreum.hash @nonce, @time, @difficulty, @prev, @data
if Equestreum.difficulty_attained hash, @difficulty
break
else
@nonce += 1
end
end
+ end
+
+ def to_h
+ h = {}
+ [
+ :data,
+ :time,
+ :hash,
+ :prev,
+ :nonce,
+ :difficulty
+ ].each do |key|
+ h[key] = self.send(key)
+ end
+ h
end
end
end