32 lines
815 B
Python
Raw Normal View History

2025-10-03 22:27:30 +02:00
from abc import ABC, abstractmethod
2026-02-05 19:45:42 +04:00
from typing import TYPE_CHECKING, AsyncIterator, Optional
2025-10-03 22:27:30 +02:00
2025-10-30 11:48:34 +01:00
from node.api.serializers.block import BlockSerializer
from node.api.serializers.health import HealthSerializer
2026-02-05 19:45:42 +04:00
from node.api.serializers.info import InfoSerializer
2025-10-03 22:27:30 +02:00
2025-11-03 13:17:19 +01:00
if TYPE_CHECKING:
from core.app import NBESettings
2025-10-03 22:27:30 +02:00
class NodeApi(ABC):
2025-11-03 13:17:19 +01:00
@abstractmethod
def __init__(self, _settings: "NBESettings"):
pass
2025-10-03 22:27:30 +02:00
@abstractmethod
2025-10-30 11:48:34 +01:00
async def get_health(self) -> HealthSerializer:
2025-10-03 22:27:30 +02:00
pass
@abstractmethod
2026-02-05 19:45:42 +04:00
async def get_info(self) -> InfoSerializer:
2025-10-15 20:53:52 +02:00
pass
@abstractmethod
2026-02-05 19:45:42 +04:00
async def get_block_by_hash(self, block_hash: str) -> Optional[BlockSerializer]:
pass
@abstractmethod
async def get_blocks_stream(self) -> AsyncIterator[BlockSerializer]:
2025-10-03 22:27:30 +02:00
pass