forked from Chia-Network/chia-blockchain
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lock for all writes (Chia-Network#1758)
* lock for all writes * use async with where convinant * wrapper * more * lint * update wallet * rl wallet * indentation * fix tests * bad path merged into main * wallet lock * refacoted by mistake * re-raise * memory/disk inconsistency * more inconsitency * asyncio.cancelled is baseexception in 3.8 and 3.9
- Loading branch information
Showing
25 changed files
with
427 additions
and
329 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import asyncio | ||
|
||
import aiosqlite | ||
|
||
|
||
class DBWrapper: | ||
""" | ||
This object handles HeaderBlocks and Blocks stored in DB used by wallet. | ||
""" | ||
|
||
db: aiosqlite.Connection | ||
lock: asyncio.Lock | ||
|
||
def __init__(self, connection: aiosqlite.Connection): | ||
self.db = connection | ||
self.lock = asyncio.Lock() | ||
|
||
async def begin_transaction(self): | ||
cursor = await self.db.execute("BEGIN TRANSACTION") | ||
await cursor.close() | ||
|
||
async def rollback_transaction(self): | ||
# Also rolls back the coin store, since both stores must be updated at once | ||
if self.db.in_transaction: | ||
cursor = await self.db.execute("ROLLBACK") | ||
await cursor.close() | ||
|
||
async def commit_transaction(self): | ||
await self.db.commit() |
Oops, something went wrong.