forked from LBRYCommunity/lbry-sdk
cleanup
This commit is contained in:
parent
ea2a583803
commit
320f5cebc7
2 changed files with 6 additions and 9 deletions
|
@ -312,19 +312,17 @@ class BaseLedger(metaclass=LedgerRegistry):
|
||||||
current = len(self.headers)
|
current = len(self.headers)
|
||||||
get_chunk = partial(self.network.retriable_call, self.network.get_headers, count=4096, b64=True)
|
get_chunk = partial(self.network.retriable_call, self.network.get_headers, count=4096, b64=True)
|
||||||
chunks = [asyncio.ensure_future(get_chunk(height)) for height in range(current, target, 4096)]
|
chunks = [asyncio.ensure_future(get_chunk(height)) for height in range(current, target, 4096)]
|
||||||
import time
|
|
||||||
start = time.time()
|
|
||||||
total = 0
|
total = 0
|
||||||
async with self.headers.checkpointed_connector() as connector:
|
async with self.headers.checkpointed_connector() as connector:
|
||||||
for chunk in chunks:
|
for chunk in chunks:
|
||||||
headers = await chunk
|
headers = await chunk
|
||||||
total += len(headers['base64'])
|
total += len(headers['base64'])
|
||||||
try:
|
connector.connect(
|
||||||
connector.connect(len(self.headers), zlib.decompress(base64.b64decode(headers['base64']), wbits=-15, bufsize=600_000))
|
len(self.headers),
|
||||||
except BaseException:
|
zlib.decompress(base64.b64decode(headers['base64']), wbits=-15, bufsize=600_000)
|
||||||
log.exception("ops")
|
)
|
||||||
log.info("Headers sync: %s / %s -- %s", connector.tell() // self.headers.header_size, target, total)
|
progress = connector.tell() // self.headers.header_size
|
||||||
print(time.time() - start)
|
log.info("Headers sync: %s / %s -- %s", progress, target, total)
|
||||||
|
|
||||||
async def update_headers(self, height=None, headers=None, subscription_update=False):
|
async def update_headers(self, height=None, headers=None, subscription_update=False):
|
||||||
rewound = 0
|
rewound = 0
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import logging
|
import logging
|
||||||
import asyncio
|
import asyncio
|
||||||
import zlib
|
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
from typing import Dict, Optional, Tuple
|
from typing import Dict, Optional, Tuple
|
||||||
from time import perf_counter
|
from time import perf_counter
|
||||||
|
|
Loading…
Reference in a new issue