Skip to content

Lib: Blockchain

valvesss edited this page Oct 11, 2019 · 1 revision

Welcome to the core!

The blockchain class handle the manipulation of blocks. It also maintain the immutable-ledger or the chain itself. It controls the requests for new blocks and new transactions over the network. And the best! It handles mining! Take a look:

  • Example:
  1. Send transactions to all peers-shared-tx-memory

data = {'company_name': 'It works!', 'company_data': 'Bloco do Bob'}

bob.bc.new_transaction(data)

  1. Mine

bob.bc.mine()

  1. Forge a new block

bob.forge_block()

  1. Requesting other nodes validation for new block

bob.bc.request_add_block()

Explanations

function: create_genesis_block

This is the easiest function! It calls the Block function and creates a new block. Then, hash this block and add this inside the block. The block is manual inserted in the chain, as the primary or first block. The genesis one.

blockchain.create_genesis_block()

PAGE IN WORK

Clone this wiki locally