Sha256: 3fe480f38b082f0857a42e9f74e3017f712b5f734e33348fbf79f1858947fe1b

Contents?: true

Size: 572 Bytes

Versions: 1

Compression:

Stored size: 572 Bytes

Contents

require 'digest'

require 'equestreum/version'
require 'equestreum/config'
require 'equestreum/block'
require 'equestreum/chain'

module Equestreum
  def self.hash nonce, difficulty, prev, data
    string = '%s%s%s%s%s' % [
      nonce,
      Time.now.to_i,
      '0' * difficulty,
      prev,
      data
    ]

    Digest::SHA256.hexdigest string
  end

  def self.difficulty_attained hash, difficulty
    hash.start_with? '0' * difficulty
  end

  class EquestreumException < Exception
    attr_reader :text

    def initialize text
      @text = text
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
equestreum-0.1.1 lib/equestreum.rb