[Python] Does every transaction create a new block in blockchain?

Discussão em 'Python' iniciado por Stack, Março 19, 2025.

  1. Stack

    Stack Membro Participativo

    class Block:
    def __init__(self, index, transactions, previous_hash):
    self.index = index
    self.transactions = transactions
    self.previous_hash = previous_hash
    self.timestamp = time()

    class BlockChain:
    self.chain = []

    def new_block(self, transactions):
    pass


    lets say I make new a transaction {'sender': 'bob', 'receiver': 'alice', 'amount': 2}

    will this transaction create a new block in the chain (i.e. self.chain.append(new_block_which_has_above_transaction)

    or will it get last block in the chain (i.e. len(self.chain)-1) and modify the self.transactions of this block.

    https://hackernoon.com/learn-blockchains-by-building-one-117428612f46 In this article, author is using self.transactions as a list and thats where I'm getting confused.

    As per my understanding, every new transaction will create a new block with that transaction and that block will be appended to blockchain. if some one mine a new block, few coins will be awarded to miner as a transaction. is that correct flow? or can a block has multiple transactions? if yes


    1. should a genesis block has multiple transactions?


    2. what if two nodes have different chain(I mean we need to resolve using consensus algorithm) but meanwhile if that node process a transaction then hash of that block would be changed and then what would happen to neighbour node's chain?

    Continue reading...

Compartilhe esta Página