connector

This commit is contained in:
4tochka 2019-05-08 21:03:32 +04:00
parent 4ad03f3aec
commit bbeecb7d47

View File

@ -222,30 +222,33 @@ class Worker:
if y["result"] is not None: if y["result"] is not None:
block = decode_block_tx(y["result"]) block = decode_block_tx(y["result"])
for z in block["tx"]: for z in block["tx"]:
tx = block["tx"][z] for i in block["tx"][z]["vIn"]:
for i in tx["vIn"]: inp = block["tx"][z]["vIn"][i]
inp = tx["vIn"][i]
outpoint = b"".join((inp["txId"], int_to_bytes(inp["vOut"]))) outpoint = b"".join((inp["txId"], int_to_bytes(inp["vOut"])))
try: try:
r = self.coins[outpoint] r = self.coins[outpoint]
tx["vIn"][i]["coin"] = (outpoint, r[0], r[1], r[2]) block["tx"][z]["vIn"][i]["__coin__"] = (outpoint, r[0], r[1], r[2])
self.destroyed_coins[outpoint] = True self.destroyed_coins[r[0]] = True
except: except:
pass pass
for i in tx["vOut"]: for i in block["tx"][z]["vOut"]:
out = tx["vOut"][i] o = b"".join((block["tx"][z]["txId"], int_to_bytes(i)))
pointer = (x << 42) + (z << 21) + i pointer = (x << 42) + (z << 21) + i
try: try:
address = out["scriptPubKey"] address = block["tx"][z]["vOut"][i]["scriptPubKey"]
except: except:
address = b"".join((bytes([out["nType"]]), out["addressHash"])) address = b"".join((bytes([block["tx"][z]["vOut"][i]["nType"]]),
o = b"".join((tx["txId"], int_to_bytes(i))) block["tx"][z]["vOut"][i]["addressHash"]))
self.coins[o] = (pointer, out["value"], address) self.coins[o] = (pointer, block["tx"][z]["vOut"][i], address)
try: for x in blocks:
out["_spent_"] = self.destroyed_coins[o] for y in blocks[x]["tx"]:
except: pass for i in blocks[x]["tx"][y]["vOut"]:
try:
pointer = (x << 42) + (y << 21) + i
blocks[x]["tx"][y]["vOut"]["__spent__"] = self.destroyed_coins[pointer]
except: pass
blocks[x] = pickle.dumps(blocks[x])
blocks[x] = pickle.dumps(block)
self.pipe_sent_msg(b'result', pickle.dumps(blocks)) self.pipe_sent_msg(b'result', pickle.dumps(blocks))
async def message_loop(self): async def message_loop(self):