def val_thread(port): val = Validator(port=port) val.create_connections() while True: val.receive() if len(val.mempool) == 5: blk = val.create_block(0, 5) print(blk) break
def new_block(): vl = Validator() for i in range(1, 10): tx = new_transaction(i) vl.add_transaction(tx) bl = vl.create_block(0, 9) print("Hashes of each transaction is :") for t in bl.sha256_txs: print(t) print("\nMerkel root of the block is ", bl.merkle_root) print("Hash of the block is ", bl.hash) # Format block to be sent to django data = { "header": "Block Header X", "hashValue": "{0}".format(bl.hash), } # Create new block and post to django requests.post("http://127.0.0.1:8000/", data=data) test_verification(vl, bl)