trivial clean-up (typing/imports)
This commit is contained in:
@@ -254,7 +254,7 @@ class ChannelDB(SqlDB):
|
|||||||
# initialized in load_data
|
# initialized in load_data
|
||||||
self._channels = {} # type: Dict[bytes, ChannelInfo]
|
self._channels = {} # type: Dict[bytes, ChannelInfo]
|
||||||
self._policies = {} # type: Dict[Tuple[bytes, bytes], Policy] # (node_id, scid) -> Policy
|
self._policies = {} # type: Dict[Tuple[bytes, bytes], Policy] # (node_id, scid) -> Policy
|
||||||
self._nodes = {}
|
self._nodes = {} # type: Dict[bytes, NodeInfo] # node_id -> NodeInfo
|
||||||
# node_id -> (host, port, ts)
|
# node_id -> (host, port, ts)
|
||||||
self._addresses = defaultdict(set) # type: Dict[bytes, Set[Tuple[str, int, int]]]
|
self._addresses = defaultdict(set) # type: Dict[bytes, Set[Tuple[str, int, int]]]
|
||||||
self._channels_for_node = defaultdict(set) # type: Dict[bytes, Set[ShortChannelID]]
|
self._channels_for_node = defaultdict(set) # type: Dict[bytes, Set[ShortChannelID]]
|
||||||
|
|||||||
@@ -26,8 +26,8 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
from typing import Sequence, List, Tuple, NamedTuple, TYPE_CHECKING
|
from typing import Sequence, List, Tuple, NamedTuple, TYPE_CHECKING
|
||||||
from enum import IntEnum, IntFlag
|
from enum import IntEnum, IntFlag
|
||||||
from Cryptodome.Cipher import ChaCha20
|
|
||||||
|
|
||||||
|
from Cryptodome.Cipher import ChaCha20
|
||||||
|
|
||||||
from . import ecc
|
from . import ecc
|
||||||
from .crypto import sha256, hmac_oneshot
|
from .crypto import sha256, hmac_oneshot
|
||||||
@@ -231,9 +231,10 @@ def generate_cipher_stream(stream_key: bytes, num_bytes: int) -> bytes:
|
|||||||
return cipher.encrypt(bytes(num_bytes))
|
return cipher.encrypt(bytes(num_bytes))
|
||||||
|
|
||||||
|
|
||||||
ProcessedOnionPacket = NamedTuple("ProcessedOnionPacket", [("are_we_final", bool),
|
class ProcessedOnionPacket(NamedTuple):
|
||||||
("hop_data", OnionHopsDataSingle),
|
are_we_final: bool
|
||||||
("next_packet", OnionPacket)])
|
hop_data: OnionHopsDataSingle
|
||||||
|
next_packet: OnionPacket
|
||||||
|
|
||||||
|
|
||||||
# TODO replay protection
|
# TODO replay protection
|
||||||
|
|||||||
@@ -320,7 +320,7 @@ class Peer(Logger):
|
|||||||
try:
|
try:
|
||||||
await asyncio.wait_for(self.initialized, LN_P2P_NETWORK_TIMEOUT)
|
await asyncio.wait_for(self.initialized, LN_P2P_NETWORK_TIMEOUT)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise GracefulDisconnect(f"Failed to initialize: {e}") from e
|
raise GracefulDisconnect(f"Failed to initialize: {e!r}") from e
|
||||||
if self.lnworker == self.lnworker.network.lngossip:
|
if self.lnworker == self.lnworker.network.lngossip:
|
||||||
try:
|
try:
|
||||||
ids, complete = await asyncio.wait_for(self.get_channel_range(), LN_P2P_NETWORK_TIMEOUT)
|
ids, complete = await asyncio.wait_for(self.get_channel_range(), LN_P2P_NETWORK_TIMEOUT)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import os
|
|||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
from typing import Optional, Sequence, Tuple, List, Dict, TYPE_CHECKING
|
from typing import Optional, Sequence, Tuple, List, Dict, TYPE_CHECKING, NamedTuple
|
||||||
import threading
|
import threading
|
||||||
import socket
|
import socket
|
||||||
import json
|
import json
|
||||||
@@ -106,8 +106,6 @@ FALLBACK_NODE_LIST_MAINNET = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
from typing import NamedTuple
|
|
||||||
|
|
||||||
class PaymentInfo(NamedTuple):
|
class PaymentInfo(NamedTuple):
|
||||||
payment_hash: bytes
|
payment_hash: bytes
|
||||||
amount: int
|
amount: int
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ class TxOutpoint(NamedTuple):
|
|||||||
def to_str(self) -> str:
|
def to_str(self) -> str:
|
||||||
return f"{self.txid.hex()}:{self.out_idx}"
|
return f"{self.txid.hex()}:{self.out_idx}"
|
||||||
|
|
||||||
def to_json(self) -> str:
|
def to_json(self):
|
||||||
return [self.txid.hex(), self.out_idx]
|
return [self.txid.hex(), self.out_idx]
|
||||||
|
|
||||||
def serialize_to_network(self) -> bytes:
|
def serialize_to_network(self) -> bytes:
|
||||||
|
|||||||
Reference in New Issue
Block a user