simplify Blockchain.clean_block_records() (#8879)

This commit is contained in:
Arvid Norberg
2021-10-20 10:38:41 -07:00
committed by GitHub
parent 8f3ea9c81b
commit 0cc4251d4f
+3 -4
View File
@@ -729,11 +729,10 @@ class Blockchain(BlockchainInterface):
if len(self.__block_records) < self.constants.BLOCKS_CACHE_SIZE:
return None
peak = self.get_peak()
assert peak is not None
if peak.height - self.constants.BLOCKS_CACHE_SIZE < 0:
assert self._peak_height is not None
if self._peak_height - self.constants.BLOCKS_CACHE_SIZE < 0:
return None
self.clean_block_record(peak.height - self.constants.BLOCKS_CACHE_SIZE)
self.clean_block_record(self._peak_height - self.constants.BLOCKS_CACHE_SIZE)
async def get_block_records_in_range(self, start: int, stop: int) -> Dict[bytes32, BlockRecord]:
return await self.block_store.get_block_records_in_range(start, stop)