Sha256: 550f08e9b1075726fc41d166c4337efd12db4092b60644ea3f12a6fec1fd0d83

Contents?: true

Size: 624 Bytes

Versions: 2

Compression:

Stored size: 624 Bytes

Contents

require 'digest'
require 'singleton'
require 'yaml'
require 'fileutils'

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

module Equestreum
  def self.hash nonce, time, difficulty, prev, data
    string = '%s%s%s%s%s' % [
      nonce,
      time,
      '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

2 entries across 2 versions & 1 rubygems

Version Path
equestreum-0.1.4 lib/equestreum.rb
equestreum-0.1.3 lib/equestreum.rb