blockchain.rb
# Create a new Block in the Blockchain
Create a new Block in the Blockchain
Create a new Block in the Blockchain
def new_block(proof:, previous_hash: nil)
    block = {
      'index' => chain.length + 1,
      'timestamp' => Time.now.to_f,
      'transactions' => current_transactions,
      'proof' => proof,
      'previous_hash' => previous_hash || hash(block: last_block)
    }
    @current_transactions = []
    chain.push(block)
    block
  end
def new_block ( proof : , previous_hash : nil ) block = { 'index' => chain . length + 1 , 'timestamp' => Time . now . to_f , 'transactions' => current_transactions , 'proof' => proof , 'previous_hash' => previous_hash || hash ( block : last_block ) } @current_transactions = [ ] chain . push ( block ) block end
Create a new Block in the Blockchain
Create a new Block in the Blockchain
# Reset the current list of transactions
proof
previous_hash