Reduce upper limit on blocks fetched at once

Testnet is lumpy and 2500 can blow up memory
This commit is contained in:
Neil Booth 2017-02-18 13:17:51 +09:00
parent 3f35bc0298
commit 790755b630

View File

@ -87,10 +87,11 @@ class Prefetcher(LoggedClass):
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.
# Constrain fetch count to between 0 and 500 regardless;
# testnet can be lumpy.
cache_room = self.min_cache_size // self.ave_size
count = min(daemon_height - self.fetched_height, cache_room)
count = min(2500, max(count, 0))
count = min(500, max(count, 0))
if not count:
if not self.caught_up:
self.caught_up = True