|
|
@ -1,4 +1,4 @@ |
|
|
|
# Copyright (c) 2016, Neil Booth |
|
|
|
# Copyright (c) 2016-2017, Neil Booth |
|
|
|
# |
|
|
|
# All rights reserved. |
|
|
|
# |
|
|
@ -88,9 +88,8 @@ class Prefetcher(LoggedClass): |
|
|
|
|
|
|
|
while True: |
|
|
|
try: |
|
|
|
with await self.semaphore: |
|
|
|
fetched = await self._prefetch_blocks(caught_up_event.is_set()) |
|
|
|
if not fetched: |
|
|
|
# Sleep a while if there is nothing to prefetch |
|
|
|
if not await self._prefetch_blocks(caught_up_event.is_set()): |
|
|
|
await asyncio.sleep(5) |
|
|
|
await self.refill_event.wait() |
|
|
|
except DaemonError as e: |
|
|
@ -106,6 +105,7 @@ class Prefetcher(LoggedClass): |
|
|
|
sleep for a period of time before returning. |
|
|
|
''' |
|
|
|
daemon_height = await self.daemon.height(mempool) |
|
|
|
with await self.semaphore: |
|
|
|
while self.cache_size < self.min_cache_size: |
|
|
|
# Try and catch up all blocks but limit to room in cache. |
|
|
|
# Constrain fetch count to between 0 and 2500 regardless. |
|
|
@ -123,6 +123,7 @@ class Prefetcher(LoggedClass): |
|
|
|
self.logger.info('new block height {:,d} hash {}' |
|
|
|
.format(first + count-1, hex_hashes[-1])) |
|
|
|
blocks = await self.daemon.raw_blocks(hex_hashes) |
|
|
|
|
|
|
|
assert count == len(blocks) |
|
|
|
|
|
|
|
# Strip the unspendable genesis coinbase |
|
|
|