Files
chia-blockchain/chia/data_layer/data_layer_api.py
ff3cf282c2 explicitly collect api methods instead of later using getattr (#18800)
* explicitly collect api methods instead of later using getattr

* api as a class itself

* tidy

* fixup

* tidier

* and...

* fixup

* oops

* mm

* hum

* fixup

* monkey patching helper

* ...

* tidy

* back to instances

* fix

* self-patch

* duplicate original request attributes

* Update chia/_tests/wallet/sync/test_wallet_sync.py

Co-authored-by: Amine Khaldi <amine.khaldi@reactos.org>

* test that `@metadata.request()` fails on repeated request type

* ...

---------

Co-authored-by: Amine Khaldi <amine.khaldi@reactos.org>
2024-11-08 08:58:15 -07:00

34 lines
969 B
Python

from __future__ import annotations
import logging
from typing import TYPE_CHECKING, ClassVar, cast
from chia.data_layer.data_layer import DataLayer
from chia.server.api_protocol import ApiMetadata
from chia.server.server import ChiaServer
class DataLayerAPI:
if TYPE_CHECKING:
from chia.server.api_protocol import ApiProtocol
_protocol_check: ClassVar[ApiProtocol] = cast("DataLayerAPI", None)
log: logging.Logger
data_layer: DataLayer
metadata: ClassVar[ApiMetadata] = ApiMetadata()
def __init__(self, data_layer: DataLayer) -> None:
self.log = logging.getLogger(__name__)
self.data_layer = data_layer
# def _set_state_changed_callback(self, callback: StateChangedProtocol) -> None:
# self.full_node.state_changed_callback = callback
@property
def server(self) -> ChiaServer:
return self.data_layer.server
def ready(self) -> bool:
return self.data_layer.initialized