Skip to content

Commit 44cb633

Browse files
committed
BlockStoreProtocol
1 parent d01758f commit 44cb633

File tree

3 files changed

+75
-1
lines changed

3 files changed

+75
-1
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
from __future__ import annotations
2+
3+
from typing import Optional, Protocol
4+
5+
from chia_rs import BlockRecord, FullBlock, SubEpochChallengeSegment
6+
from chia_rs.sized_bytes import bytes32
7+
from chia_rs.sized_ints import uint32
8+
9+
from chia.full_node.full_block_utils import GeneratorBlockInfo
10+
11+
12+
class BlockStoreProtocol(Protocol):
13+
async def add_full_block(self, header_hash: bytes32, block: FullBlock, block_record: BlockRecord) -> None: ...
14+
15+
async def get_full_block(self, header_hash: bytes32) -> Optional[FullBlock]: ...
16+
17+
async def get_full_block_bytes(self, header_hash: bytes32) -> Optional[bytes]: ...
18+
19+
async def get_full_blocks_at(self, heights: list[uint32]) -> list[FullBlock]: ...
20+
21+
async def get_block_info(self, header_hash: bytes32) -> Optional[GeneratorBlockInfo]: ...
22+
23+
async def get_generator(self, header_hash: bytes32) -> Optional[bytes]: ...
24+
25+
async def get_generators_at(self, heights: set[uint32]) -> dict[uint32, bytes]: ...
26+
27+
async def get_block_record(self, header_hash: bytes32) -> Optional[BlockRecord]: ...
28+
29+
async def get_block_records_in_range(
30+
self,
31+
start: int,
32+
stop: int,
33+
) -> dict[bytes32, BlockRecord]: ...
34+
35+
async def get_block_records_by_hash(self, header_hashes: list[bytes32]) -> list[BlockRecord]: ...
36+
37+
async def get_block_bytes_by_hash(self, header_hashes: list[bytes32]) -> list[bytes]: ...
38+
39+
async def get_blocks_by_hash(self, header_hashes: list[bytes32]) -> list[FullBlock]: ...
40+
41+
async def get_peak(self) -> Optional[tuple[bytes32, uint32]]: ...
42+
43+
async def get_block_bytes_in_range(
44+
self,
45+
start: int,
46+
stop: int,
47+
) -> list[bytes]: ...
48+
49+
async def get_random_not_compactified(self, number: int) -> list[int]: ...
50+
51+
async def persist_sub_epoch_challenge_segments(
52+
self, ses_block_hash: bytes32, segments: list[SubEpochChallengeSegment]
53+
) -> None: ...
54+
55+
async def get_sub_epoch_challenge_segments(
56+
self,
57+
ses_block_hash: bytes32,
58+
) -> Optional[list[SubEpochChallengeSegment]]: ...
59+
60+
async def rollback(self, height: int) -> None: ...
61+
62+
async def set_in_chain(self, header_hashes: list[tuple[bytes32]]) -> None: ...
63+
64+
async def set_peak(self, header_hash: bytes32) -> None: ...
65+
66+
async def is_fully_compactified(self, header_hash: bytes32) -> Optional[bool]: ...
67+
68+
async def replace_proof(self, header_hash: bytes32, block: FullBlock) -> None: ...
69+
70+
async def count_compactified_blocks(self) -> int: ...
71+
72+
async def count_uncompactified_blocks(self) -> int: ...

chia/full_node/block_store.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from chia_rs.sized_bytes import bytes32
1212
from chia_rs.sized_ints import uint32
1313

14+
from chia.consensus.block_store_protocol import BlockStoreProtocol
1415
from chia.full_node.full_block_utils import GeneratorBlockInfo, block_info_from_block, generator_from_block
1516
from chia.util.db_wrapper import DBWrapper2, execute_fetchone
1617
from chia.util.errors import Err

chia/full_node/full_node.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
from chia.consensus.block_body_validation import ForkInfo
4141
from chia.consensus.block_creation import unfinished_block_to_full_block
4242
from chia.consensus.block_height_map import BlockHeightMap
43+
from chia.consensus.block_store_protocol import BlockStoreProtocol
4344
from chia.consensus.blockchain import AddBlockResult, Blockchain, BlockchainMutexPriority, StateChangeSummary
4445
from chia.consensus.blockchain_interface import BlockchainInterface
4546
from chia.consensus.coin_store_protocol import CoinStoreProtocol
@@ -399,7 +400,7 @@ async def manage(self) -> AsyncIterator[None]:
399400
await asyncio.gather(*self._segment_task_list, return_exceptions=True)
400401

401402
@property
402-
def block_store(self) -> BlockStore:
403+
def block_store(self) -> BlockStoreProtocol:
403404
assert self._block_store is not None
404405
return self._block_store
405406

0 commit comments

Comments
 (0)