Skip to content

Commit c37222d

Browse files
authored
Reduce memory requirement by clearing header list (#82)
1 parent 035a8df commit c37222d

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/blockchain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ async def pre_validate_blocks(
706706
if pos is not None:
707707
pos = bytes32(pos)
708708
results[i] = val, pos
709-
pool.shutdown()
709+
pool.shutdown(wait=True)
710710
return results
711711

712712
@staticmethod

src/full_node.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,8 @@ async def _sync(self) -> OutboundMessageGenerator:
386386
f"Validated weight of headers. Downloaded {len(headers)} headers, tip height {tip_height}"
387387
)
388388
assert tip_height == fork_point_height + len(headers)
389+
self.store.clear_potential_headers()
390+
headers.clear()
389391

390392
# Download blocks in batches, and verify them as they come in. We download a few batches ahead,
391393
# in case there are delays.

src/store.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ def add_potential_header(self, block: HeaderBlock) -> None:
183183
def get_potential_header(self, height: uint32) -> Optional[HeaderBlock]:
184184
return self.potential_headers.get(height, None)
185185

186+
def clear_potential_headers(self) -> None:
187+
self.potential_headers.clear()
188+
186189
def set_potential_hashes(self, potential_hashes: List[bytes32]) -> None:
187190
self.potential_hashes = potential_hashes
188191

0 commit comments

Comments
 (0)