Skip to content

Commit

Permalink
potential peak and fork debug info. also changed sleep from 2 to 60
Browse files Browse the repository at this point in the history
  • Loading branch information
wjblanke authored and hoffmang9 committed Jan 22, 2021
1 parent a25cca4 commit e48e802
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/full_node/full_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,12 @@ async def _sync(self):
"""
try:
self.log.info("Starting to perform sync with peers.")
self.log.info("Waiting to receive peaks from peers.")
self.log.info("Waiting to receive peaks from peers. Sleeping 60 seconds.")
self.sync_peers_handler = None
self.sync_store.waiting_for_peaks = True

await asyncio.sleep(2)
await asyncio.sleep(60)
self.log.info("Woke up from 60 second sleep.")
# Based on responses from peers about the current heads, see which head is the heaviest
# (similar to longest chain rule).
self.sync_store.waiting_for_peaks = False
Expand Down
3 changes: 3 additions & 0 deletions src/full_node/sync_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def get_potential_peaks_tuples(self) -> List[Tuple[bytes32, Tuple[uint32, uint12
return list(self.potential_peaks.items())

def add_potential_peak(self, header_hash: bytes32, sub_height: uint32, weight: uint128) -> None:
log.info(f"add_potential_peak header_hash {header_hash} sub_height {sub_height} weight {weight}")
self.potential_peaks[header_hash] = (sub_height, weight)

def get_potential_peak(self, header_hash: bytes32) -> Optional[Tuple[uint32, uint128]]:
Expand All @@ -104,9 +105,11 @@ def get_potential_future_blocks(self):
return self.potential_future_blocks

def add_potential_fork_point(self, peak_hash: bytes32, fork_point: uint32):
log.info(f"add_potential_fork_point peak_hash {peak_hash} fork_point {fork_point}")
self.peak_fork_point[peak_hash] = fork_point

def get_potential_fork_point(self, peak_hash) -> uint32:
log.info(f"get_potential_fork_point peak_hash {peak_hash} peak_fork_point {self.peak_fork_point}")
if peak_hash in self.peak_fork_point:
return self.peak_fork_point[peak_hash]
else:
Expand Down

0 comments on commit e48e802

Please sign in to comment.