def mine(): transactions = get_transactions() transactions = [Transaction.from_dict(x) for x in transactions] last_block = get_last_block() block = Block(last_block['id'] + 1, transactions, 0) while not block.get_hash(last_block['hash']).startswith('0000'): block.nonce += 1 block.set_hash(block.get_hash(last_block['hash'])) r = requests.post(b_url + '/add_block', json=block.to_dict()) return r.text
def add_transaction(): data = request.json transaction = Transaction.from_dict(data) transaction_pool.append(transaction) return jsonify({"status": "OK"})