Sha256: 4162ecbb9394a926ca9363ebb22f35558e9ded5b002f207dcaf780518fd942c0

Contents?: true

Size: 487 Bytes

Versions: 2

Compression:

Stored size: 487 Bytes

Contents

module Equestreum
  class Block
    attr_accessor :data, :prev, :difficulty
    attr_reader :hash, :nonce, :time

    def initialize
      @difficulty = 4

      yield self if block_given?
    end

    def mine
      @time = Time.now.to_i
      @nonce = 0
      loop do
        @hash = Equestreum.hash @nonce, @difficulty, @prev, @data
        if Equestreum.difficulty_attained hash, @difficulty
          break
        else
          @nonce += 1
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
equestreum-0.1.1 lib/equestreum/block.rb
equestreum-0.1.0 lib/equestreum/block.rb