connector
This commit is contained in:
parent
ef0bb809e1
commit
e97d3787df
@ -145,6 +145,7 @@ class Connector:
|
|||||||
# if self.preload:
|
# if self.preload:
|
||||||
# self.loop.create_task(self.preload_block())
|
# self.loop.create_task(self.preload_block())
|
||||||
# self.loop.create_task(self.preload_block_hashes())
|
# self.loop.create_task(self.preload_block_hashes())
|
||||||
|
await self.preload_block_hashes()
|
||||||
self.loop.create_task(self.get_next_block())
|
self.loop.create_task(self.get_next_block())
|
||||||
|
|
||||||
async def utxo_init(self):
|
async def utxo_init(self):
|
||||||
@ -572,27 +573,24 @@ class Connector:
|
|||||||
|
|
||||||
|
|
||||||
async def preload_block_hashes(self):
|
async def preload_block_hashes(self):
|
||||||
while True:
|
max_height = self.node_last_block - self.deep_synchronization
|
||||||
|
height = self.last_block_height + 1
|
||||||
|
while height < max_height:
|
||||||
try:
|
try:
|
||||||
start_height = self.last_block_height
|
batch = list()
|
||||||
height = start_height + 10
|
while True:
|
||||||
d = await self.rpc.getblockcount()
|
batch.append(["getblockhash", height])
|
||||||
if d > height:
|
if len(batch) >= self.batch_limit or height >= max_height:
|
||||||
while True:
|
break
|
||||||
height += 1
|
result = await self.rpc.batch(batch)
|
||||||
d = await self.rpc.getblockhash(height)
|
self.log.warning(str(height))
|
||||||
ex = self.block_preload.get(d)
|
|
||||||
if not ex:
|
|
||||||
b = await self.rpc.getblock(d)
|
|
||||||
self.block_hashes_preload.set(d, b)
|
|
||||||
if start_height + 15000 < height:
|
|
||||||
break
|
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
self.log.info("connector preload_block_hashes terminated")
|
self.log.info("connector preload_block_hashes failed")
|
||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
await asyncio.sleep(10)
|
|
||||||
|
|
||||||
async def preload_block(self):
|
async def preload_block(self):
|
||||||
while True:
|
while True:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user