connector
This commit is contained in:
parent
07ad03bb6a
commit
2de3d7e73e
@ -200,56 +200,59 @@ class Worker:
|
|||||||
self.loop.run_forever()
|
self.loop.run_forever()
|
||||||
|
|
||||||
async def load_blocks(self, height):
|
async def load_blocks(self, height):
|
||||||
batch = list()
|
try:
|
||||||
h_list = list()
|
batch = list()
|
||||||
while True:
|
h_list = list()
|
||||||
batch.append(["getblockhash", height])
|
while True:
|
||||||
h_list.append(height)
|
batch.append(["getblockhash", height])
|
||||||
if len(batch) >= self.rpc_batch_limit:
|
h_list.append(height)
|
||||||
|
if len(batch) >= self.rpc_batch_limit:
|
||||||
|
height += 1
|
||||||
|
break
|
||||||
height += 1
|
height += 1
|
||||||
break
|
result = await self.rpc.batch(batch)
|
||||||
height += 1
|
h = list()
|
||||||
result = await self.rpc.batch(batch)
|
batch = list()
|
||||||
h = list()
|
for lh, r in zip(h_list, result):
|
||||||
batch = list()
|
if r["result"] is not None:
|
||||||
for lh, r in zip(h_list, result):
|
batch.append(["getblock", r["result"], 0])
|
||||||
if r["result"] is not None:
|
h.append(lh)
|
||||||
batch.append(["getblock", r["result"], 0])
|
result = await self.rpc.batch(batch)
|
||||||
h.append(lh)
|
blocks = dict()
|
||||||
result = await self.rpc.batch(batch)
|
for x, y in zip(h, result):
|
||||||
blocks = dict()
|
if y["result"] is not None:
|
||||||
for x, y in zip(h, result):
|
block = decode_block_tx(y["result"])
|
||||||
if y["result"] is not None:
|
for z in block["rawTx"]:
|
||||||
block = decode_block_tx(y["result"])
|
for i in block["rawTx"][z]["vIn"]:
|
||||||
for z in block["rawTx"]:
|
inp = block["rawTx"][z]["vIn"][i]
|
||||||
for i in block["rawTx"][z]["vIn"]:
|
outpoint = b"".join((inp["txId"], int_to_bytes(inp["vOut"])))
|
||||||
inp = block["rawTx"][z]["vIn"][i]
|
try:
|
||||||
outpoint = b"".join((inp["txId"], int_to_bytes(inp["vOut"])))
|
r = self.coins[outpoint]
|
||||||
|
block["rawTx"][z]["vIn"][i]["__coin__"] = (outpoint, r[0], r[1], r[2])
|
||||||
|
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
|
||||||
|
try:
|
||||||
|
address = block["rawTx"][z]["vOut"][i]["scriptPubKey"]
|
||||||
|
except:
|
||||||
|
address = b"".join((bytes([block["rawTx"][z]["vOut"][i]["nType"]]),
|
||||||
|
block["rawTx"][z]["vOut"][i]["addressHash"]))
|
||||||
|
self.coins[o] = (pointer, block["rawTx"][z]["vOut"][i], address)
|
||||||
|
for x in blocks:
|
||||||
|
for y in blocks[x]["rawTx"]:
|
||||||
|
for i in blocks[x]["rawTx"][y]["vOut"]:
|
||||||
try:
|
try:
|
||||||
r = self.coins[outpoint]
|
pointer = (x << 42) + (y << 21) + i
|
||||||
block["rawTx"][z]["vIn"][i]["__coin__"] = (outpoint, r[0], r[1], r[2])
|
blocks[x]["rawTx"][y]["vOut"]["__spent__"] = self.destroyed_coins[pointer]
|
||||||
self.destroyed_coins[r[0]] = True
|
except: pass
|
||||||
except:
|
blocks[x] = pickle.dumps(blocks[x])
|
||||||
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
|
|
||||||
try:
|
|
||||||
address = block["rawTx"][z]["vOut"][i]["scriptPubKey"]
|
|
||||||
except:
|
|
||||||
address = b"".join((bytes([block["rawTx"][z]["vOut"][i]["nType"]]),
|
|
||||||
block["rawTx"][z]["vOut"][i]["addressHash"]))
|
|
||||||
self.coins[o] = (pointer, block["rawTx"][z]["vOut"][i], address)
|
|
||||||
for x in blocks:
|
|
||||||
for y in blocks[x]["rawTx"]:
|
|
||||||
for i in blocks[x]["rawTx"][y]["vOut"]:
|
|
||||||
try:
|
|
||||||
pointer = (x << 42) + (y << 21) + i
|
|
||||||
blocks[x]["rawTx"][y]["vOut"]["__spent__"] = self.destroyed_coins[pointer]
|
|
||||||
except: pass
|
|
||||||
blocks[x] = pickle.dumps(blocks[x])
|
|
||||||
|
|
||||||
self.pipe_sent_msg(b'result', pickle.dumps(blocks))
|
self.pipe_sent_msg(b'result', pickle.dumps(blocks))
|
||||||
|
except:
|
||||||
|
self.log.critical(str(traceback.format_exc()))
|
||||||
|
|
||||||
async def message_loop(self):
|
async def message_loop(self):
|
||||||
try:
|
try:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user