class Rubychain::Block

Attributes

data[R]
hash[R]
index[R]
prev_hash[R]
timestamp[R]

Public Class Methods

new(index, timestamp, data, prev_hash) click to toggle source
# File lib/rubychain/block.rb, line 8
def initialize(index, timestamp, data, prev_hash)
  @index = index
  @timestamp = timestamp
  @data = data
  @prev_hash = prev_hash
  @hash = hash_block
end

Public Instance Methods

hash_block() click to toggle source

Create the blocks hash by encrypting all the blocks data using SHA256

# File lib/rubychain/block.rb, line 18
def hash_block
  hash_string = [index,timestamp,data,prev_hash].join
  sha = Digest::SHA256.new
  sha.update(hash_string)
  sha.hexdigest
end