Spaces:
Sleeping
Sleeping
File size: 951 Bytes
b073cce |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
from abc import ABC, abstractmethod
from typing import List
from dataclasses import dataclass
from aiohttp.web_response import Response
@dataclass
class QueryValidatorParams:
k_miners: int
exclude: List[str]
roles: List[str]
messages: List[str]
timeout: int
prefer: str
@staticmethod
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):
@abstractmethod
async def query_validator(self, params:QueryValidatorParams) -> Response:
pass
class MockValidator(ValidatorWrapper):
async def query_validator(self, params:QueryValidatorParams) -> Response:
...
|