Sha256: c29433cae5b79e5c24f02b2ac0f58e45fe7fc53fb082b3363ee96fa578405835

Contents?: true

Size: 544 Bytes

Versions: 1

Compression:

Stored size: 544 Bytes

Contents

require 'digest'

require 'equestreum/version'
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.0 lib/equestreum.rb