Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make sure we set the syncto height correctly when we roll back instea… #11389

Merged
merged 2 commits into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions chia/wallet/wallet_blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ async def get_peak_block(self) -> Optional[HeaderBlock]:
return self._peak
return await self._basic_store.get_object("PEAK_BLOCK", HeaderBlock)

async def set_finished_sync_up_to(self, height: int, in_transaction=False):
if height > await self.get_finished_sync_up_to():
async def set_finished_sync_up_to(self, height: int, in_transaction=False, in_rollback=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rename this argument to: allow_rollback

if (in_rollback and height >= 0) or (height > await self.get_finished_sync_up_to()):
await self._basic_store.set_object("FINISHED_SYNC_UP_TO", uint32(height), in_transaction)
if not in_transaction:
await self.clean_block_records()
Expand Down
2 changes: 1 addition & 1 deletion chia/wallet/wallet_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ async def perform_atomic_rollback(self, fork_height: int, cache: Optional[PeerRe
try:
await self.wallet_state_manager.db_wrapper.begin_transaction()
removed_wallet_ids = await self.wallet_state_manager.reorg_rollback(fork_height)
await self.wallet_state_manager.blockchain.set_finished_sync_up_to(fork_height, True)
await self.wallet_state_manager.blockchain.set_finished_sync_up_to(fork_height, True, in_rollback=True)
if cache is None:
self.rollback_request_caches(fork_height)
else:
Expand Down