diff --git a/README.md b/README.md index da9cf77..00734cb 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ Scribe maintains a rocksdb database containing the [LBRY blockchain](https://git * Protobuf schema for encoding and decoding metadata stored on the blockchain ([scribe.schema](https://github.com/lbryio/scribe/tree/master/scribe/schema)). * Blockchain processor that maintains an up to date rocksdb database ([scribe.blockchain](https://github.com/lbryio/scribe/tree/master/scribe/blockchain)) * Rocksdb based database containing the blockchain data ([scribe.db](https://github.com/lbryio/scribe/tree/master/scribe/db)) - * Interface for python services to implement in order for them maintain a read only view of the blockchain data ([scribe.readers.interface](https://github.com/lbryio/scribe/tree/master/scribe/readers/interface.py)) - * Electrum based server for thin-wallet clients like lbry-sdk ([scribe.readers.hub_server](https://github.com/lbryio/scribe/tree/master/scribe/readers/hub_server.py)) - * Elasticsearch sync utility to index all the claim metadata in the blockchain into an easily searchable form ([scribe.readers.elastic_sync](https://github.com/lbryio/scribe/tree/master/scribe/readers/elastic_sync.py)) + * Interface for python services to implement in order for them maintain a read only view of the blockchain data ([scribe.reader.interface](https://github.com/lbryio/scribe/tree/master/scribe/reader/interface.py)) + * Electrum based server for thin-wallet clients like lbry-sdk ([scribe.reader.hub_server](https://github.com/lbryio/scribe/tree/master/scribe/reader/hub_server.py)) + * Elasticsearch sync utility to index all the claim metadata in the blockchain into an easily searchable form ([scribe.reader.elastic_sync](https://github.com/lbryio/scribe/tree/master/scribe/reader/elastic_sync.py)) ## Installation diff --git a/scribe/cli.py b/scribe/cli.py index a424c82..a7413be 100644 --- a/scribe/cli.py +++ b/scribe/cli.py @@ -3,7 +3,7 @@ import traceback import argparse from scribe.env import Env from scribe.blockchain.block_processor import BlockProcessor -from scribe.readers import BlockchainReaderServer, ElasticWriter +from scribe.reader import BlockchainReaderServer, ElasticWriter def get_arg_parser(name): diff --git a/scribe/hub/common.py b/scribe/hub/common.py index 96ca47e..3991c9e 100644 --- a/scribe/hub/common.py +++ b/scribe/hub/common.py @@ -1,16 +1,7 @@ -import logging -import itertools -import time -import json -import typing -import asyncio import inspect -from asyncio import Event from collections import namedtuple -from functools import partial, lru_cache -from numbers import Number -from asyncio import Queue -from scribe.common import RPCError, CodeMessageError +from functools import lru_cache +from scribe.common import CodeMessageError HISTOGRAM_BUCKETS = ( diff --git a/scribe/hub/session.py b/scribe/hub/session.py index dedb14a..86d5b08 100644 --- a/scribe/hub/session.py +++ b/scribe/hub/session.py @@ -21,7 +21,6 @@ from scribe.base58 import Base58Error from scribe.error import ResolveCensoredError, TooManyClaimSearchParametersError from scribe import __version__, PROTOCOL_MIN, PROTOCOL_MAX, PROMETHEUS_NAMESPACE from scribe.build_info import BUILD, COMMIT_HASH, DOCKER_TAG -from scribe.db import HubDB from scribe.elasticsearch import SearchIndex from scribe.common import sha256, hash_to_hex_str, hex_str_to_hash, HASHX_LEN, version_string, formatted_time from scribe.common import protocol_version, RPCError, DaemonError, TaskGroup @@ -29,6 +28,7 @@ from scribe.hub.jsonrpc import JSONRPCAutoDetect, JSONRPCConnection, JSONRPCv2, from scribe.hub.common import BatchRequest, ProtocolError, Request, Batch, Notification from scribe.hub.framer import NewlineFramer if typing.TYPE_CHECKING: + from scribe.db import HubDB from scribe.env import Env from scribe.blockchain.daemon import LBCDaemon from scribe.hub.mempool import MemPool @@ -249,7 +249,7 @@ class SessionManager: namespace=NAMESPACE, buckets=HISTOGRAM_BUCKETS ) - def __init__(self, env: 'Env', db: HubDB, mempool: 'MemPool', history_cache, resolve_cache, resolve_outputs_cache, + def __init__(self, env: 'Env', db: 'HubDB', mempool: 'MemPool', history_cache, resolve_cache, resolve_outputs_cache, 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) @@ -1144,7 +1144,7 @@ class LBRYElectrumX(SessionBase): self.protocol_tuple = self.PROTOCOL_MIN self.protocol_string = None self.daemon = self.session_manager.daemon - self.db: HubDB = self.session_manager.db + self.db: 'HubDB' = self.session_manager.db @classmethod def protocol_min_max_strings(cls): diff --git a/scribe/reader/__init__.py b/scribe/reader/__init__.py new file mode 100644 index 0000000..9f464a6 --- /dev/null +++ b/scribe/reader/__init__.py @@ -0,0 +1,3 @@ +from scribe.reader.interface import BaseBlockchainReader +from scribe.reader.hub_server import BlockchainReaderServer +from scribe.reader.elastic_sync import ElasticWriter diff --git a/scribe/readers/elastic_sync.py b/scribe/reader/elastic_sync.py similarity index 99% rename from scribe/readers/elastic_sync.py rename to scribe/reader/elastic_sync.py index 17afcec..6761f55 100644 --- a/scribe/readers/elastic_sync.py +++ b/scribe/reader/elastic_sync.py @@ -17,7 +17,7 @@ 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 -from scribe.readers import BaseBlockchainReader +from scribe.reader import BaseBlockchainReader from scribe.db.revertable import RevertableOp from scribe.db.common import TrendingNotification, DB_PREFIXES diff --git a/scribe/readers/hub_server.py b/scribe/reader/hub_server.py similarity index 99% rename from scribe/readers/hub_server.py rename to scribe/reader/hub_server.py index 2d8938f..681c713 100644 --- a/scribe/readers/hub_server.py +++ b/scribe/reader/hub_server.py @@ -3,7 +3,7 @@ import asyncio import typing from scribe import __version__ from scribe.blockchain.daemon import LBCDaemon -from scribe.readers import BaseBlockchainReader +from scribe.reader import BaseBlockchainReader from scribe.elasticsearch import ElasticNotifierClientProtocol from scribe.hub.session import SessionManager from scribe.hub.mempool import MemPool diff --git a/scribe/readers/interface.py b/scribe/reader/interface.py similarity index 100% rename from scribe/readers/interface.py rename to scribe/reader/interface.py diff --git a/scribe/readers/__init__.py b/scribe/readers/__init__.py deleted file mode 100644 index 0c47c7d..0000000 --- a/scribe/readers/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from scribe.readers.interface import BaseBlockchainReader -from scribe.readers.hub_server import BlockchainReaderServer -from scribe.readers.elastic_sync import ElasticWriter