def __init__(self, prev_blocks: Sequence[IBlock] = None, name: Optional[str] = None): Block.__init__(self, None, 1, name=name) if prev_blocks is not None: for b in prev_blocks: if b is not None: self.conn_to_prev_block(b)
def createBlock(self, myAddress): parent = self._blockchain.getMaxHeightBlock() prevHash = parent._hash utxoPool = self._blockchain.getMaxHeightUTXOPool() txsPool = self._blockchain.getTransactionPool() txs = txsPool.getTransactions() handler = TxHandler(utxoPool) validTxs = handler.handleTxs(txs) current = Block(prevHash, myAddress, validTxs, parent._height + 1, None) current.finalize() if self._blockchain.addBlock(current): return current return None
def __init__(self): Block.__init__(self, None, 2)