connector

This commit is contained in:
4tochka 2019-05-17 14:18:45 +04:00
parent e815ee10e1
commit e1be200cbd
2 changed files with 18 additions and 7 deletions

View File

@ -218,6 +218,7 @@ class Worker:
async def load_blocks(self, height): async def load_blocks(self, height):
try: try:
t = 0 t = 0
start_height = height
batch = list() batch = list()
h_list = list() h_list = list()
while True: while True:
@ -247,7 +248,11 @@ class Worker:
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.delete(outpoint) r = self.coins.delete(outpoint)
block["rawTx"][z]["vIn"][i]["_c_"] = r h = r[0] >> 42
if h >= start_height and h < height:
block["rawTx"][z]["vIn"][i]["_a_"] = r
else:
block["rawTx"][z]["vIn"][i]["_c_"] = r
t += 1 t += 1
self.destroyed_coins[r[0]] = True self.destroyed_coins[r[0]] = True
except: except:

View File

@ -614,18 +614,24 @@ class Connector:
self.destroyed_coins += 1 self.destroyed_coins += 1
inp = tx["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"])))
tx["vIn"][i]["outpoint"] = outpoint
try: try:
tx["vIn"][i]["outpoint"] = outpoint
tx["vIn"][i]["coin"] = inp["_c_"] tx["vIn"][i]["coin"] = inp["_c_"]
c += 1 c += 1
self.yy += 1 self.yy += 1
except: except:
r = self.utxo.get(outpoint) try:
if r: tx["vIn"][i]["coin"] = inp["_c_"]
tx["vIn"][i]["coin"] = r
c += 1 c += 1
else: self.yy += 1
missed.add((outpoint, (block_height << 42) + (block_index << 21) + i, i)) self.utxo.deleted.add(outpoint)
except:
r = self.utxo.get(outpoint)
if r:
tx["vIn"][i]["coin"] = r
c += 1
else:
missed.add((outpoint, (block_height << 42) + (block_index << 21) + i, i))
if missed: if missed:
await self.utxo.load_utxo() await self.utxo.load_utxo()