connector

This commit is contained in:
4tochka 2019-05-09 01:34:03 +04:00
parent f40d1610ab
commit 9d7285263f
2 changed files with 32 additions and 29 deletions

View File

@ -595,10 +595,13 @@ class Connector:
if self.utxo: if self.utxo:
stxo, missed = set(), set() stxo, missed = set(), set()
for i in tx["vIn"]: for i in tx["vIn"]:
inp = tx["vIn"][i] try:
outpoint = b"".join((inp["txId"], int_to_bytes(inp["vOut"]))) stxo.add(tx["vIn"][i]["__coin__"])
r = self.utxo.get(outpoint, block_height) except:
stxo.add(r) if r else missed.add((outpoint, (block_height << 42) + (block_index << 21) + i)) inp = tx["vIn"][i]
outpoint = b"".join((inp["txId"], int_to_bytes(inp["vOut"])))
r = self.utxo.get(outpoint, block_height)
stxo.add(r) if r else missed.add((outpoint, (block_height << 42) + (block_index << 21) + i))
if missed: if missed:
await self.utxo.load_utxo() await self.utxo.load_utxo()

View File

@ -223,33 +223,33 @@ class Worker:
for x, y in zip(h, result): for x, y in zip(h, result):
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["rawTx"]: # for z in block["rawTx"]:
for i in block["rawTx"][z]["vIn"]: # for i in block["rawTx"][z]["vIn"]:
inp = block["rawTx"][z]["vIn"][i] # inp = block["rawTx"][z]["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]
block["rawTx"][z]["vIn"][i]["__coin__"] = (outpoint, r[0], r[1], r[2]) # block["rawTx"][z]["vIn"][i]["__coin__"] = (outpoint, r[0], r[1], r[2])
self.destroyed_coins[r[0]] = True # self.destroyed_coins[r[0]] = True
except: # except:
pass # pass
for i in block["rawTx"][z]["vOut"]: # for i in block["rawTx"][z]["vOut"]:
o = b"".join((block["rawTx"][z]["txId"], int_to_bytes(i))) # o = b"".join((block["rawTx"][z]["txId"], int_to_bytes(i)))
pointer = (x << 42) + (z << 21) + i # pointer = (x << 42) + (z << 21) + i
try: # try:
address = block["rawTx"][z]["vOut"][i]["scriptPubKey"] # address = block["rawTx"][z]["vOut"][i]["scriptPubKey"]
except: # except:
address = b"".join((bytes([block["rawTx"][z]["vOut"][i]["nType"]]), # address = b"".join((bytes([block["rawTx"][z]["vOut"][i]["nType"]]),
block["rawTx"][z]["vOut"][i]["addressHash"])) # block["rawTx"][z]["vOut"][i]["addressHash"]))
self.coins[o] = (pointer, block["rawTx"][z]["vOut"][i], address) # self.coins[o] = (pointer, block["rawTx"][z]["vOut"][i], address)
blocks[x] = block blocks[x] = block
for x in blocks: for x in blocks:
for y in blocks[x]["rawTx"]: # for y in blocks[x]["rawTx"]:
for i in blocks[x]["rawTx"][y]["vOut"]: # for i in blocks[x]["rawTx"][y]["vOut"]:
try: # try:
pointer = (x << 42) + (y << 21) + i # pointer = (x << 42) + (y << 21) + i
blocks[x]["rawTx"][y]["vOut"][i]["__spent__"] = self.destroyed_coins[pointer] # blocks[x]["rawTx"][y]["vOut"][i]["__spent__"] = self.destroyed_coins[pointer]
except: pass # except: pass
blocks[x] = pickle.dumps(blocks[x]) blocks[x] = pickle.dumps(blocks[x])
# self.log.critical(str(len(blocks))) # self.log.critical(str(len(blocks)))
self.pipe_sent_msg(b'result', pickle.dumps(blocks)) self.pipe_sent_msg(b'result', pickle.dumps(blocks))