Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion hathor/daa.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,20 @@
NOTE: This module could use a better name.
"""

from __future__ import annotations

from enum import IntFlag
from math import log
from typing import TYPE_CHECKING, Callable, ClassVar, Optional

from structlog import get_logger

from hathor.conf.settings import HathorSettings
from hathor.profiler import get_cpu_profiler
from hathor.types import VertexId
from hathor.util import iwindows

if TYPE_CHECKING:
from hathor.conf.settings import HathorSettings
from hathor.transaction import Block, Transaction

logger = get_logger()
Expand Down
4 changes: 3 additions & 1 deletion hathor/indexes/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import annotations

import operator
from abc import ABC, abstractmethod
from functools import reduce
from typing import TYPE_CHECKING, Iterator, Optional

from structlog import get_logger

from hathor.conf.settings import HathorSettings
from hathor.indexes.address_index import AddressIndex
from hathor.indexes.base_index import BaseIndex
from hathor.indexes.height_index import HeightIndex
Expand All @@ -33,6 +34,7 @@
from hathor.util import tx_progress

if TYPE_CHECKING: # pragma: no cover
from hathor.conf.settings import HathorSettings
from hathor.pubsub import PubSubManager
from hathor.storage import RocksDBStorage
from hathor.transaction.storage import TransactionStorage
Expand Down
4 changes: 3 additions & 1 deletion hathor/reward_lock/reward_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import annotations

from typing import TYPE_CHECKING, Iterator, Optional

from hathor.conf.settings import HathorSettings
from hathor.transaction import Block
from hathor.util import not_none

if TYPE_CHECKING:
from hathor.conf.settings import HathorSettings
from hathor.transaction.storage.vertex_storage_protocol import VertexStorageProtocol
from hathor.transaction.transaction import RewardLockedInfo, Transaction

Expand Down
6 changes: 1 addition & 5 deletions hathor/transaction/storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,10 @@

from hathor.transaction.storage.cache_storage import TransactionCacheStorage
from hathor.transaction.storage.memory_storage import TransactionMemoryStorage
from hathor.transaction.storage.rocksdb_storage import TransactionRocksDBStorage
from hathor.transaction.storage.transaction_storage import TransactionStorage
from hathor.transaction.storage.vertex_storage_protocol import VertexStorageProtocol

try:
from hathor.transaction.storage.rocksdb_storage import TransactionRocksDBStorage
except ImportError:
pass

__all__ = [
'TransactionStorage',
'TransactionMemoryStorage',
Expand Down
8 changes: 5 additions & 3 deletions hathor/transaction/storage/cache_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@
# limitations under the License.

from collections import OrderedDict
from typing import Any, Iterator, Optional
from typing import TYPE_CHECKING, Any, Iterator, Optional

from twisted.internet import threads
from typing_extensions import override

from hathor.conf.settings import HathorSettings
from hathor.indexes import IndexesManager
from hathor.reactor import ReactorProtocol as Reactor
from hathor.transaction import BaseTransaction
from hathor.transaction.storage.migrations import MigrationState
from hathor.transaction.storage.transaction_storage import BaseTransactionStorage
from hathor.transaction.storage.tx_allow_scope import TxAllowScope

if TYPE_CHECKING:
from hathor.conf.settings import HathorSettings


class TransactionCacheStorage(BaseTransactionStorage):
"""Caching storage to be used 'on top' of other storages.
Expand All @@ -41,7 +43,7 @@ def __init__(
interval: int = 5,
capacity: int = 10000,
*,
settings: HathorSettings,
settings: 'HathorSettings',
indexes: Optional[IndexesManager],
_clone_if_needed: bool = False,
) -> None:
Expand Down
8 changes: 5 additions & 3 deletions hathor/transaction/storage/memory_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Any, Iterator, Optional, TypeVar
from typing import TYPE_CHECKING, Any, Iterator, Optional, TypeVar

from typing_extensions import override

from hathor.conf.settings import HathorSettings
from hathor.indexes import IndexesManager
from hathor.transaction import BaseTransaction
from hathor.transaction.storage.exceptions import TransactionDoesNotExist
from hathor.transaction.storage.migrations import MigrationState
from hathor.transaction.storage.transaction_storage import BaseTransactionStorage
from hathor.transaction.transaction_metadata import TransactionMetadata

if TYPE_CHECKING:
from hathor.conf.settings import HathorSettings

_Clonable = TypeVar('_Clonable', BaseTransaction, TransactionMetadata)


Expand All @@ -32,7 +34,7 @@ def __init__(
self,
indexes: Optional[IndexesManager] = None,
*,
settings: HathorSettings,
settings: 'HathorSettings',
_clone_if_needed: bool = False,
) -> None:
"""
Expand Down
4 changes: 2 additions & 2 deletions hathor/transaction/storage/rocksdb_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from structlog import get_logger
from typing_extensions import override

from hathor.conf.settings import HathorSettings
from hathor.indexes import IndexesManager
from hathor.storage import RocksDBStorage
from hathor.transaction.static_metadata import VertexStaticMetadata
Expand All @@ -29,6 +28,7 @@
if TYPE_CHECKING:
import rocksdb

from hathor.conf.settings import HathorSettings
from hathor.transaction import BaseTransaction

logger = get_logger()
Expand All @@ -52,7 +52,7 @@ def __init__(
rocksdb_storage: RocksDBStorage,
indexes: Optional[IndexesManager] = None,
*,
settings: HathorSettings,
settings: 'HathorSettings',
vertex_parser: VertexParser,
) -> None:
self._cf_tx = rocksdb_storage.get_or_create_column_family(_CF_NAME_TX)
Expand Down
8 changes: 6 additions & 2 deletions hathor/transaction/storage/transaction_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import annotations

import hashlib
from abc import ABC, abstractmethod, abstractproperty
from collections import deque
from contextlib import AbstractContextManager
from threading import Lock
from typing import Any, Iterator, NamedTuple, Optional, cast
from typing import TYPE_CHECKING, Any, Iterator, NamedTuple, Optional, cast
from weakref import WeakValueDictionary

from intervaltree.interval import Interval
from structlog import get_logger

from hathor.conf.settings import HathorSettings
from hathor.execution_manager import ExecutionManager
from hathor.indexes import IndexesManager
from hathor.indexes.height_index import HeightInfo
Expand All @@ -50,6 +51,9 @@
from hathor.types import VertexId
from hathor.verification.transaction_verifier import TransactionVerifier

if TYPE_CHECKING:
from hathor.conf.settings import HathorSettings

cpu = get_cpu_profiler()

# these are the timestamp values to be used when resetting them, 1 is used for the node instead of 0, so it can be
Expand Down
3 changes: 1 addition & 2 deletions hathor/transaction/vertex_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
from struct import error as StructError
from typing import TYPE_CHECKING

from hathor.conf.settings import HathorSettings

if TYPE_CHECKING:
from hathor.conf.settings import HathorSettings
from hathor.transaction import BaseTransaction
from hathor.transaction.storage import TransactionStorage

Expand Down
8 changes: 7 additions & 1 deletion hathor/verification/transaction_verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from hathor.conf.settings import HathorSettings
from __future__ import annotations

from typing import TYPE_CHECKING

from hathor.daa import DifficultyAdjustmentAlgorithm
from hathor.profiler import get_cpu_profiler
from hathor.reward_lock import get_spent_reward_locked_info
Expand All @@ -39,6 +42,9 @@
from hathor.transaction.util import get_deposit_amount, get_withdraw_amount
from hathor.types import TokenUid, VertexId

if TYPE_CHECKING:
from hathor.conf.settings import HathorSettings

cpu = get_cpu_profiler()


Expand Down
Loading