def __init__(self):
self.chain = [self.create_genesis_block()]
self.difficulty = 4 Adjust difficulty here
self.pending_transactions = []
def create_genesis_block(self):
return Block(0, time.time(), "Genesis Block", "0")
def get_latest_block(self):
return self.chain[1]
def add_block(self, new_block):
new_block.previous_hash = self.get_latest_block().hash
new_block.mine_block(self.difficulty)
self.chain.append(new_block)
def add_transaction(self, sender, receiver, amount):
self.pending_transactions.append({"sender": sender, "receiver": receiver, "amount": amount})
def mine_pending_transactions(self, miner_reward_address):
block = Block(len(self.chain), time.time(), self.pending_transactions, self.get_latest_block().hash)
block.mine_block(self.difficulty)
print("Block successfully mined.) center no-repeat; background-size:cover;">