Sha256: 34ec7966bbd55a305ee751399dfeeb281debf3759effbaa7890cf557848b3c03

Contents?: true

Size: 604 Bytes

Versions: 1

Compression:

Stored size: 604 Bytes

Contents

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

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

1 entries across 1 versions & 1 rubygems

Version Path
equestreum-0.1.2 lib/equestreum.rb