Spaces:
Sleeping
Sleeping
from abc import ABC, abstractmethod | |
from typing import List | |
from dataclasses import dataclass | |
from aiohttp.web_response import Response | |
class QueryValidatorParams: | |
k_miners: int | |
exclude: List[str] | |
roles: List[str] | |
messages: List[str] | |
timeout: int | |
prefer: str | |
def from_dict(data: dict): | |
return QueryValidatorParams( | |
k_miners=data.get('k', 10), | |
exclude=data.get('exclude', []), | |
roles=data['roles'], | |
messages=data['messages'], | |
timeout=data.get('timeout', 10), | |
prefer=data.get('prefer', 'longest') | |
) | |
class ValidatorWrapper(ABC): | |
async def query_validator(self, params:QueryValidatorParams) -> Response: | |
pass | |
class MockValidator(ValidatorWrapper): | |
async def query_validator(self, params:QueryValidatorParams) -> Response: | |
... | |