Retour au sujet

Avatar de JwC JwC
def __init__(self):
self.chain = []
self.generate_genesis_block()

def generate_genesis_block(self):
self.chain.append(Hope("0", ['Hope']))

def create_block_from_transaction(self, transaction_list):
previous_block_hash = self.last_block.block_hash
self.chain.append(Hope(previous_block_hash, transaction_list))

def display_chain(self):
for i in range(len(self.chain)):
print(f"Data {i + 1}: {self.chain[i].block_data}")
print(f"Hash {i + 1}: {self.chain[i].block_hash}\n")

@property
def last_block(self):
return self.chain[-1]

https://image.noelshack.com/minis/2023/51/3/1703093334-1703093030-1703084518753493-crop-33.png