Skip to content

Commit 4e8c24f

Browse files
committed
more
1 parent 8720984 commit 4e8c24f

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

chia/_tests/blockchain/test_blockchain.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3886,7 +3886,8 @@ async def test_chain_failed_rollback(empty_blockchain: Blockchain, bt: BlockTool
38863886
print(f"{recs_dbg1[0] if len(recs_dbg1) > 0 else None}")
38873887
print(spend_bundle.coin_spends[0].coin.name())
38883888
# await b.consensus_store._set_spent([spend_bundle.coin_spends[0].coin.name()], 8)
3889-
await b.consensus_store.rollback_to_block(2)
3889+
async with b.consensus_store as writer:
3890+
await writer.rollback_to_block(2)
38903891
recs_dbg2 = await b.consensus_store.get_coin_records([spend_bundle.coin_spends[0].coin.name()])
38913892
print(f"{recs_dbg2[0] if len(recs_dbg2) > 0 else None}")
38923893

chia/consensus/consensus_store_protocol.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from collections.abc import Collection
44
from typing import AsyncIterator, Optional, Protocol
5+
from types import TracebackType
56

67
from chia_rs import BlockRecord, FullBlock, SubEpochChallengeSegment, SubEpochSummary
78
from chia_rs.sized_bytes import bytes32
@@ -61,7 +62,12 @@ class ConsensusStoreProtocol(Protocol):
6162

6263
# Async context manager methods
6364
async def __aenter__(self) -> ConsensusStoreWriteProtocol: ...
64-
async def __aexit__(self, exc_type, exc, tb) -> Optional[bool]: ...
65+
async def __aexit__(
66+
self,
67+
exc_type: Optional[type[BaseException]],
68+
exc: Optional[BaseException],
69+
tb: Optional[TracebackType],
70+
) -> Optional[bool]: ...
6571

6672
# Block store reads
6773
async def get_block_records_close_to_peak(

chia/full_node/consensus_store_sqlite3.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from collections.abc import Collection
55
from contextlib import AbstractAsyncContextManager
66
from typing import Any, AsyncIterator, Optional, TYPE_CHECKING
7+
from types import TracebackType
78

89
from chia_rs import BlockRecord, FullBlock, SubEpochChallengeSegment, SubEpochSummary
910
from chia_rs.sized_bytes import bytes32
@@ -97,7 +98,12 @@ async def __aenter__(self):
9798
self._txn_depth += 1
9899
return self._writer # Return the same writer for nested contexts
99100

100-
async def __aexit__(self, exc_type, exc, tb):
101+
async def __aexit__(
102+
self,
103+
exc_type: Optional[type[BaseException]],
104+
exc: Optional[BaseException],
105+
tb: Optional[TracebackType],
106+
) -> Optional[bool]:
101107
try:
102108
# Check if we're at the outermost level before decrementing
103109
if self._txn_depth == 1:

0 commit comments

Comments
 (0)