connector

This commit is contained in:
4tochka 2019-05-17 13:08:38 +04:00
parent 6736fa0dfe
commit a0e3b2f10e
2 changed files with 14 additions and 13 deletions

View File

@ -241,16 +241,17 @@ class Worker:
if y["result"] is not None:
block = decode_block_tx(y["result"])
for z in block["rawTx"]:
for i in block["rawTx"][z]["vIn"]:
inp = block["rawTx"][z]["vIn"][i]
outpoint = b"".join((inp["txId"], int_to_bytes(inp["vOut"])))
try:
r = self.coins.delete(outpoint)
block["rawTx"][z]["vIn"][i]["_c_"] = r
t += 1
self.destroyed_coins[r[0]] = True
except:
pass
if not block["rawTx"][z]["coinbase"]:
for i in block["rawTx"][z]["vIn"]:
inp = block["rawTx"][z]["vIn"][i]
outpoint = b"".join((inp["txId"], int_to_bytes(inp["vOut"])))
try:
r = self.coins.delete(outpoint)
block["rawTx"][z]["vIn"][i]["_c_"] = r
t += 1
self.destroyed_coins[r[0]] = True
except:
pass
for i in block["rawTx"][z]["vOut"]:
o = b"".join((block["rawTx"][z]["txId"], int_to_bytes(i)))
pointer = (x << 42) + (z << 21) + i
@ -273,7 +274,6 @@ class Worker:
except: pass
blocks[x] = pickle.dumps(blocks[x])
self.log.critical("worker [%s]" % self.name)
self.pipe_sent_msg(b'result', pickle.dumps(blocks))
except:
self.pipe_sent_msg(b'result', pickle.dumps([]))

View File

@ -342,14 +342,15 @@ class Connector:
async def _new_block(self, block):
tq = time.time()
if not self.active or not self.active_block.done() or self.last_block_height >= block["height"]:
return
try:
if self.block_headers_cache.get(block["hash"]) is not None:
return
if self.deep_synchronization:
block["height"] = self.last_block_height + 1
if not self.active or not self.active_block.done() or self.last_block_height >= block["height"]:
return
self.active_block = asyncio.Future()
self.log.debug("Block %s %s" % (block["height"], block["hash"]))