2022-09-30 11:40:22 +03:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2023-06-13 19:25:15 +03:00
|
|
|
import logging
|
2023-06-13 23:25:39 +03:00
|
|
|
from typing import Optional
|
2021-11-28 05:30:25 +03:00
|
|
|
|
2022-09-08 20:57:15 +03:00
|
|
|
from chia.protocols import full_node_protocol, wallet_protocol
|
2021-11-28 05:30:25 +03:00
|
|
|
from chia.seeder.crawler import Crawler
|
|
|
|
from chia.server.outbound_message import Message
|
2022-09-08 20:57:15 +03:00
|
|
|
from chia.server.server import ChiaServer
|
2022-11-08 19:10:59 +03:00
|
|
|
from chia.server.ws_connection import WSChiaConnection
|
2022-10-20 23:10:23 +03:00
|
|
|
from chia.util.api_decorators import api_request
|
2021-11-28 05:30:25 +03:00
|
|
|
|
|
|
|
|
|
|
|
class CrawlerAPI:
|
2023-06-14 04:12:25 +03:00
|
|
|
log: logging.Logger
|
2021-11-28 05:30:25 +03:00
|
|
|
crawler: Crawler
|
|
|
|
|
2023-06-13 19:25:15 +03:00
|
|
|
def __init__(self, crawler: Crawler) -> None:
|
2023-06-14 04:12:25 +03:00
|
|
|
self.log = logging.getLogger(__name__)
|
2021-11-28 05:30:25 +03:00
|
|
|
self.crawler = crawler
|
|
|
|
|
|
|
|
@property
|
2022-09-08 20:57:15 +03:00
|
|
|
def server(self) -> ChiaServer:
|
|
|
|
assert self.crawler.server is not None
|
2021-11-28 05:30:25 +03:00
|
|
|
return self.crawler.server
|
|
|
|
|
2023-06-14 04:12:25 +03:00
|
|
|
def ready(self) -> bool:
|
|
|
|
return True
|
2021-11-28 05:30:25 +03:00
|
|
|
|
2022-10-20 23:10:23 +03:00
|
|
|
@api_request(peer_required=True)
|
2023-06-13 19:25:15 +03:00
|
|
|
async def request_peers(
|
|
|
|
self, _request: full_node_protocol.RequestPeers, peer: WSChiaConnection
|
|
|
|
) -> Optional[Message]:
|
2021-11-28 05:30:25 +03:00
|
|
|
pass
|
|
|
|
|
2022-10-20 23:10:23 +03:00
|
|
|
@api_request(peer_required=True)
|
2021-11-28 05:30:25 +03:00
|
|
|
async def respond_peers(
|
2022-11-08 19:10:59 +03:00
|
|
|
self, request: full_node_protocol.RespondPeers, peer: WSChiaConnection
|
2021-11-28 05:30:25 +03:00
|
|
|
) -> Optional[Message]:
|
|
|
|
pass
|
|
|
|
|
2022-10-20 23:10:23 +03:00
|
|
|
@api_request(peer_required=True)
|
2022-11-08 19:10:59 +03:00
|
|
|
async def new_peak(self, request: full_node_protocol.NewPeak, peer: WSChiaConnection) -> Optional[Message]:
|
2021-11-28 05:30:25 +03:00
|
|
|
await self.crawler.new_peak(request, peer)
|
|
|
|
return None
|
|
|
|
|
2022-10-20 23:10:23 +03:00
|
|
|
@api_request()
|
2021-11-28 05:30:25 +03:00
|
|
|
async def new_transaction(self, transaction: full_node_protocol.NewTransaction) -> Optional[Message]:
|
|
|
|
pass
|
|
|
|
|
2022-10-20 23:10:23 +03:00
|
|
|
@api_request(peer_required=True)
|
2021-11-28 05:30:25 +03:00
|
|
|
async def new_signage_point_or_end_of_sub_slot(
|
2022-11-08 19:10:59 +03:00
|
|
|
self, new_sp: full_node_protocol.NewSignagePointOrEndOfSubSlot, peer: WSChiaConnection
|
2021-11-28 05:30:25 +03:00
|
|
|
) -> Optional[Message]:
|
|
|
|
pass
|
|
|
|
|
2022-10-20 23:10:23 +03:00
|
|
|
@api_request()
|
2021-11-28 05:30:25 +03:00
|
|
|
async def new_unfinished_block(
|
|
|
|
self, new_unfinished_block: full_node_protocol.NewUnfinishedBlock
|
|
|
|
) -> Optional[Message]:
|
|
|
|
pass
|
|
|
|
|
2022-10-20 23:10:23 +03:00
|
|
|
@api_request(peer_required=True)
|
2023-06-13 19:25:15 +03:00
|
|
|
async def new_compact_vdf(
|
|
|
|
self, request: full_node_protocol.NewCompactVDF, peer: WSChiaConnection
|
|
|
|
) -> Optional[Message]:
|
2021-11-28 05:30:25 +03:00
|
|
|
pass
|
|
|
|
|
2022-10-20 23:10:23 +03:00
|
|
|
@api_request()
|
2021-11-28 05:30:25 +03:00
|
|
|
async def request_transaction(self, request: full_node_protocol.RequestTransaction) -> Optional[Message]:
|
|
|
|
pass
|
|
|
|
|
2022-10-20 23:10:23 +03:00
|
|
|
@api_request()
|
2021-11-28 05:30:25 +03:00
|
|
|
async def request_proof_of_weight(self, request: full_node_protocol.RequestProofOfWeight) -> Optional[Message]:
|
|
|
|
pass
|
|
|
|
|
2022-10-20 23:10:23 +03:00
|
|
|
@api_request()
|
2021-11-28 05:30:25 +03:00
|
|
|
async def request_block(self, request: full_node_protocol.RequestBlock) -> Optional[Message]:
|
|
|
|
pass
|
|
|
|
|
2022-10-20 23:10:23 +03:00
|
|
|
@api_request()
|
2021-11-28 05:30:25 +03:00
|
|
|
async def request_blocks(self, request: full_node_protocol.RequestBlocks) -> Optional[Message]:
|
|
|
|
pass
|
|
|
|
|
2022-10-20 23:10:23 +03:00
|
|
|
@api_request()
|
2021-11-28 05:30:25 +03:00
|
|
|
async def request_unfinished_block(
|
|
|
|
self, request_unfinished_block: full_node_protocol.RequestUnfinishedBlock
|
|
|
|
) -> Optional[Message]:
|
|
|
|
pass
|
|
|
|
|
2022-10-20 23:10:23 +03:00
|
|
|
@api_request()
|
2021-11-28 05:30:25 +03:00
|
|
|
async def request_signage_point_or_end_of_sub_slot(
|
|
|
|
self, request: full_node_protocol.RequestSignagePointOrEndOfSubSlot
|
|
|
|
) -> Optional[Message]:
|
|
|
|
pass
|
|
|
|
|
2022-10-20 23:10:23 +03:00
|
|
|
@api_request(peer_required=True)
|
2021-11-28 05:30:25 +03:00
|
|
|
async def request_mempool_transactions(
|
|
|
|
self,
|
|
|
|
request: full_node_protocol.RequestMempoolTransactions,
|
2022-11-08 19:10:59 +03:00
|
|
|
peer: WSChiaConnection,
|
2021-11-28 05:30:25 +03:00
|
|
|
) -> Optional[Message]:
|
|
|
|
pass
|
|
|
|
|
2022-10-20 23:10:23 +03:00
|
|
|
@api_request()
|
2021-11-28 05:30:25 +03:00
|
|
|
async def request_block_header(self, request: wallet_protocol.RequestBlockHeader) -> Optional[Message]:
|
|
|
|
pass
|
|
|
|
|
2022-10-20 23:10:23 +03:00
|
|
|
@api_request()
|
2021-11-28 05:30:25 +03:00
|
|
|
async def request_additions(self, request: wallet_protocol.RequestAdditions) -> Optional[Message]:
|
|
|
|
pass
|
|
|
|
|
2022-10-20 23:10:23 +03:00
|
|
|
@api_request()
|
2021-11-28 05:30:25 +03:00
|
|
|
async def request_removals(self, request: wallet_protocol.RequestRemovals) -> Optional[Message]:
|
|
|
|
pass
|
|
|
|
|
2022-10-20 23:10:23 +03:00
|
|
|
@api_request()
|
2021-11-28 05:30:25 +03:00
|
|
|
async def request_puzzle_solution(self, request: wallet_protocol.RequestPuzzleSolution) -> Optional[Message]:
|
|
|
|
pass
|
|
|
|
|
2022-10-20 23:10:23 +03:00
|
|
|
@api_request()
|
2021-11-28 05:30:25 +03:00
|
|
|
async def request_header_blocks(self, request: wallet_protocol.RequestHeaderBlocks) -> Optional[Message]:
|
|
|
|
pass
|