Skip to content

Commit c9408be

Browse files
committed
ruff
1 parent de804ae commit c9408be

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

chia/_tests/blockchain/blockchain_test_utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import Optional
3+
from typing import Optional, cast
44

55
from chia_rs import FullBlock, SpendBundleConditions
66
from chia_rs.sized_ints import uint32, uint64
@@ -10,19 +10,20 @@
1010
from chia.consensus.blockchain import AddBlockResult, Blockchain
1111
from chia.consensus.difficulty_adjustment import get_next_sub_slot_iters_and_difficulty
1212
from chia.consensus.multiprocess_validation import PreValidationResult, pre_validate_block
13+
from chia.full_node.block_store import BlockStore
1314
from chia.types.validation_state import ValidationState
1415
from chia.util.errors import Err
1516

1617

1718
async def check_block_store_invariant(bc: Blockchain):
18-
db_wrapper = bc.block_store.db_wrapper
19+
block_store = cast(BlockStore, bc.block_store)
1920

20-
if db_wrapper.db_version == 1:
21+
if block_store.db_wrapper.db_version == 1:
2122
return
2223

2324
in_chain = set()
2425
max_height = -1
25-
async with db_wrapper.writer_maybe_transaction() as conn:
26+
async with block_store.transaction() as conn:
2627
async with conn.execute("SELECT height, in_main_chain FROM full_blocks") as cursor:
2728
rows = await cursor.fetchall()
2829
for row in rows:

chia/consensus/block_store_protocol.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from contextlib import AbstractAsyncContextManager
4-
from typing import Optional, Protocol
4+
from typing import Any, Optional, Protocol
55

66
from chia_rs import BlockRecord, FullBlock, SubEpochChallengeSegment
77
from chia_rs.sized_bytes import bytes32
@@ -47,4 +47,4 @@ async def get_block_records_close_to_peak(
4747
) -> tuple[dict[bytes32, BlockRecord], Optional[bytes32]]: ...
4848
def get_host_parameter_limit(self) -> int: ...
4949
async def get_prev_hash(self, header_hash: bytes32) -> bytes32: ...
50-
def transaction(self) -> AbstractAsyncContextManager[None]: ...
50+
def transaction(self) -> AbstractAsyncContextManager[Any]: ...

chia/simulator/full_node_simulator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ async def revert_block_height(self, new_height: uint32) -> None:
167167
raise ValueError("Cannot revert to a height less than 1.")
168168
block_record: BlockRecord = self.full_node.blockchain.height_to_block_record(new_height)
169169
# remove enough data to allow a bunch of blocks to be wiped.
170-
async with self.full_node.block_store.db_wrapper.writer():
170+
async with self.full_node.block_store.transaction():
171171
# set coinstore
172172
await self.full_node.coin_store.rollback_to_block(new_height)
173173
# set blockstore to new height

0 commit comments

Comments
 (0)