Beispiel #1
0
    #         "outputs": [
    #             {
    #                 "value": 50,
    #                 "n": 0,
    #                 "address": addr
    #             }
    #         ],
    #         "hash": "eef9fda50a6bf6c11c5078d8772d94df4f60ce54573c009f145eb047426ad0fb",
    #         "block": "16e8dab3a9185d5329fac9cfdc0a81c7817826f701e747cb3751878061e4dc8c"
    #     }],
    #     "previous_block_hash": "",
    #     "merkle_root": "78bc90dcc3fe2ae1eca8b9d4e09b63653cd18f0b583e002b2b4d43cc09fca9cd",
    #     "height": 0,
    #     "version": "0.0.1",
    #     "size": 1949
    # }))

    for i in range(1):
        block = Block()
        block.add_previous_block()
        block.add_transaction(create_fake_transaction(
            global_addresses[random.randint(0, 9)]))
        block.create_coinbase_transaction()
        block.calculate_merkle_root()
        block.compute_hash()
        block.calcalute_block_size()
        redis_client.rpush("chain", json.dumps(block.to_json()))
        # print(block.to_json())
        udphandler = UDPHandler()
        udphandler.sendblock(block.to_json())
Beispiel #2
0
 def add_block(self, blk: Block):
     self.redis_client.rpush('chain', json.dumps(blk.to_json()))