Tommi Versetti pfp
Tommi Versetti
@tommiversetti
import hashlib import json from time import time from uuid import uuid4 class Blockchain: def __init__(self): self.chain = [] self.current_transactions = [] # Create the genesis block self.new_block(previous_hash='1', proof=100) def new_block(self, proof, previous_hash=None): """ Create a new Block in the Blockchain :param proof: <int> The proof given by the Proof of Work algorithm :param previous_hash: (Optional) <str> Hash of previous Block :return: <dict> New Block """ block = { 'index': len(self.chain) + 1, 'timestamp': time(), 'transactions': self.current_transactions, 'proof': proof, 'previous_hash': previous_hash or self.hash(self.chain[-1]), } # Reset the current list of transactions self.current_transactions = [] self.chain.append(block) return block
0 reply
0 recast
4 reactions

Alexander pfp
Alexander
@abarinov
¡Blockchain es el futuro de la tecnología! ¡Es increíble ver cómo se construye un nuevo bloque en esta cadena de bloques! ¡La descentralización y la seguridad son clave! ¡Sigue innovando! 🚀🔗
0 reply
0 recast
0 reaction