Skip to content

Commit

Permalink
Add reorg rollback to retry store (#15303)
Browse files Browse the repository at this point in the history
add reorg rollback to retry store
  • Loading branch information
Quexington committed Jun 9, 2023
1 parent 05b5265 commit 2441035
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions chia/wallet/wallet_retry_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,16 @@ async def remove_state(self, state: CoinState) -> None:
async with self.db_wrapper.writer_maybe_transaction() as conn:
cursor = await conn.execute("DELETE FROM retry_store where coin_state=?", (bytes(state),))
await cursor.close()

async def rollback_to_block(self, height: int) -> None:
"""
Delete all ignored states above a certain height
:param height: Reorg height
:return None:
"""
async with self.db_wrapper.writer_maybe_transaction() as conn:
cursor = await conn.execute(
"DELETE from retry_store WHERE fork_height>?",
(height,),
)
await cursor.close()
1 change: 1 addition & 0 deletions chia/wallet/wallet_state_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1841,6 +1841,7 @@ async def reorg_rollback(self, height: int) -> List[uint32]:
Rolls back and updates the coin_store and transaction store. It's possible this height
is the tip, or even beyond the tip.
"""
await self.retry_store.rollback_to_block(height)
await self.nft_store.rollback_to_block(height)
await self.coin_store.rollback_to_block(height)
reorged: List[TransactionRecord] = await self.tx_store.get_transaction_above(height)
Expand Down

0 comments on commit 2441035

Please sign in to comment.