mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2026-08-24 10:05:29 -05:00
Move some files closer to where they should live. (#18465)
* Move to `chia.full_node.util.safe_cancel_task` * Move to `chia/wallet/util/pprint.py` * Separate out `IPAddress` into `ip_address.py`
This commit is contained in:
@@ -7,7 +7,8 @@ from typing import Union
|
||||
|
||||
import pytest
|
||||
|
||||
from chia.util.network import IPAddress, resolve
|
||||
from chia.util.ip_address import IPAddress
|
||||
from chia.util.network import resolve
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from chia.util.pprint import print_compact_ranges
|
||||
from chia.wallet.util.pprint import print_compact_ranges
|
||||
|
||||
|
||||
def test_print_compact_ranges() -> None:
|
||||
|
||||
@@ -11,7 +11,7 @@ from typing import Any, Optional
|
||||
from chia.util.collection import find_duplicates
|
||||
from chia.util.db_synchronous import db_synchronous_on
|
||||
from chia.util.db_wrapper import DBWrapper2, execute_fetchone
|
||||
from chia.util.pprint import print_compact_ranges
|
||||
from chia.wallet.util.pprint import print_compact_ranges
|
||||
from chia.wallet.util.wallet_types import WalletType
|
||||
|
||||
# TODO: Check for missing paired wallets (eg. No DID wallet for an NFT)
|
||||
|
||||
@@ -42,6 +42,7 @@ from chia.full_node.signage_point import SignagePoint
|
||||
from chia.full_node.subscriptions import PeerSubscriptions, peers_for_spend_bundle
|
||||
from chia.full_node.sync_store import Peak, SyncStore
|
||||
from chia.full_node.tx_processing_queue import TransactionQueue
|
||||
from chia.full_node.util.safe_cancel_task import cancel_task_safe
|
||||
from chia.full_node.weight_proof import WeightProofHandler
|
||||
from chia.protocols import farmer_protocol, full_node_protocol, timelord_protocol, wallet_protocol
|
||||
from chia.protocols.farmer_protocol import SignagePointSourceData, SPSubSlotSourceData, SPVDFSourceData
|
||||
@@ -85,7 +86,6 @@ from chia.util.limited_semaphore import LimitedSemaphore
|
||||
from chia.util.log_exceptions import log_exceptions
|
||||
from chia.util.path import path_from_root
|
||||
from chia.util.profiler import enable_profiler, mem_profile_task, profile_task
|
||||
from chia.util.safe_cancel_task import cancel_task_safe
|
||||
|
||||
|
||||
# This is the result of calling peak_post_processing, which is then fed into peak_post_processing_2
|
||||
|
||||
@@ -24,7 +24,8 @@ from chia.server.ws_connection import WSChiaConnection
|
||||
from chia.types.peer_info import PeerInfo, TimestampedPeerInfo, UnresolvedPeerInfo
|
||||
from chia.util.hash import std_hash
|
||||
from chia.util.ints import uint16, uint64
|
||||
from chia.util.network import IPAddress, resolve
|
||||
from chia.util.ip_address import IPAddress
|
||||
from chia.util.network import resolve
|
||||
|
||||
MAX_PEERS_RECEIVED_PER_REQUEST = 1000
|
||||
MAX_TOTAL_PEERS_RECEIVED = 3000
|
||||
|
||||
@@ -5,7 +5,7 @@ from dataclasses import dataclass
|
||||
from typing import Union
|
||||
|
||||
from chia.util.ints import uint16, uint64
|
||||
from chia.util.network import IPAddress
|
||||
from chia.util.ip_address import IPAddress
|
||||
from chia.util.streamable import Streamable, streamable
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from ipaddress import IPv4Address, IPv6Address, ip_address
|
||||
from typing import Union
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class IPAddress:
|
||||
_inner: Union[IPv4Address, IPv6Address]
|
||||
|
||||
@classmethod
|
||||
def create(cls, ip: str) -> IPAddress:
|
||||
return cls(ip_address(ip))
|
||||
|
||||
def __int__(self) -> int:
|
||||
return int(self._inner)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return str(self._inner)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return repr(self._inner)
|
||||
|
||||
@property
|
||||
def packed(self) -> bytes:
|
||||
return self._inner.packed
|
||||
|
||||
@property
|
||||
def is_private(self) -> bool:
|
||||
return self._inner.is_private
|
||||
|
||||
@property
|
||||
def is_v4(self) -> bool:
|
||||
return self._inner.version == 4
|
||||
|
||||
@property
|
||||
def is_v6(self) -> bool:
|
||||
return self._inner.version == 6
|
||||
+2
-35
@@ -7,7 +7,7 @@ import socket
|
||||
import ssl
|
||||
from collections.abc import Iterable
|
||||
from dataclasses import dataclass
|
||||
from ipaddress import IPv4Address, IPv4Network, IPv6Address, IPv6Network, ip_address
|
||||
from ipaddress import IPv4Network, IPv6Network, ip_address
|
||||
from typing import Any, Literal, Optional, Union
|
||||
|
||||
from aiohttp import web
|
||||
@@ -17,40 +17,7 @@ from typing_extensions import final
|
||||
from chia.server.outbound_message import NodeType
|
||||
from chia.types.blockchain_format.sized_bytes import bytes32
|
||||
from chia.util.ints import uint16
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class IPAddress:
|
||||
_inner: Union[IPv4Address, IPv6Address]
|
||||
|
||||
@classmethod
|
||||
def create(cls, ip: str) -> IPAddress:
|
||||
return cls(ip_address(ip))
|
||||
|
||||
def __int__(self) -> int:
|
||||
return int(self._inner)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return str(self._inner)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return repr(self._inner)
|
||||
|
||||
@property
|
||||
def packed(self) -> bytes:
|
||||
return self._inner.packed
|
||||
|
||||
@property
|
||||
def is_private(self) -> bool:
|
||||
return self._inner.is_private
|
||||
|
||||
@property
|
||||
def is_v4(self) -> bool:
|
||||
return self._inner.version == 4
|
||||
|
||||
@property
|
||||
def is_v6(self) -> bool:
|
||||
return self._inner.version == 6
|
||||
from chia.util.ip_address import IPAddress
|
||||
|
||||
|
||||
@final
|
||||
|
||||
Reference in New Issue
Block a user