type annotations

This commit is contained in:
Jack Robison 2022-05-05 16:41:55 -04:00
parent 6f22767486
commit bda9561178
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
4 changed files with 13 additions and 7 deletions

View file

@ -19,7 +19,7 @@ from scribe.blockchain.mempool import MemPool
from scribe.schema.url import normalize_name
from scribe.service import BlockchainService
if typing.TYPE_CHECKING:
from scribe.env import Env
from scribe.blockchain.env import BlockchainEnv
from scribe.db.revertable import RevertableOpStack
@ -43,7 +43,7 @@ class BlockchainProcessorService(BlockchainService):
"reorg_count", "Number of reorgs", namespace=NAMESPACE
)
def __init__(self, env: 'Env'):
def __init__(self, env: 'BlockchainEnv'):
super().__init__(env, secondary_name='', thread_workers=1, thread_prefix='block-processor')
self.daemon = LBCDaemon(env.coin, env.daemon_url)
self.mempool = MemPool(env.coin, self.db)

View file

@ -13,13 +13,16 @@ from scribe.elasticsearch.notifier_protocol import ElasticNotifierProtocol
from scribe.elasticsearch.search import IndexVersionMismatch, expand_query
from scribe.elasticsearch.constants import ALL_FIELDS, INDEX_DEFAULT_SETTINGS
from scribe.elasticsearch.fast_ar_trending import FAST_AR_TRENDING_SCRIPT
if typing.TYPE_CHECKING:
from scribe.elasticsearch.env import ElasticEnv
class ElasticSyncService(BlockchainReaderService):
VERSION = 1
def __init__(self, env):
def __init__(self, env: 'ElasticEnv'):
super().__init__(env, 'lbry-elastic-writer', thread_workers=1, thread_prefix='lbry-elastic-writer')
self.env = env
# self._refresh_interval = 0.1
self._task = None
self.index = self.env.es_index_prefix + 'claims'

View file

@ -1,5 +1,5 @@
import time
import typing
import asyncio
from scribe.blockchain.daemon import LBCDaemon
from scribe.hub.session import SessionManager
@ -7,11 +7,14 @@ from scribe.hub.mempool import HubMemPool
from scribe.hub.udp import StatusServer
from scribe.service import BlockchainReaderService
from scribe.elasticsearch import ElasticNotifierClientProtocol
if typing.TYPE_CHECKING:
from scribe.hub.env import ServerEnv
class HubServerService(BlockchainReaderService):
def __init__(self, env):
def __init__(self, env: 'ServerEnv'):
super().__init__(env, 'lbry-reader', thread_workers=max(1, env.max_query_workers), thread_prefix='hub-worker')
self.env = env
self.notifications_to_send = []
self.mempool_notifications = set()
self.status_server = StatusServer()

View file

@ -28,7 +28,7 @@ from scribe.hub.common import BatchRequest, ProtocolError, Request, Batch, Notif
from scribe.hub.framer import NewlineFramer
if typing.TYPE_CHECKING:
from scribe.db import HubDB
from scribe.env import Env
from scribe.hub.env import ServerEnv
from scribe.blockchain.daemon import LBCDaemon
from scribe.hub.mempool import HubMemPool
@ -164,7 +164,7 @@ class SessionManager:
namespace=NAMESPACE, buckets=HISTOGRAM_BUCKETS
)
def __init__(self, env: 'Env', db: 'HubDB', mempool: 'HubMemPool',
def __init__(self, env: 'ServerEnv', db: 'HubDB', mempool: 'HubMemPool',
daemon: 'LBCDaemon', shutdown_event: asyncio.Event,
on_available_callback: typing.Callable[[], None], on_unavailable_callback: typing.Callable[[], None]):
env.max_send = max(350000, env.max_send)