Skip to content

Commit

Permalink
chore: update dependencies (#998)
Browse files Browse the repository at this point in the history
  • Loading branch information
glevco authored Aug 20, 2024
1 parent 78dcca1 commit 7f03142
Show file tree
Hide file tree
Showing 7 changed files with 351 additions and 352 deletions.
7 changes: 4 additions & 3 deletions hathor/p2p/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import TYPE_CHECKING, Any, Iterable, NamedTuple, Optional, Union
from typing import TYPE_CHECKING, Any, Iterable, NamedTuple, Optional

from structlog import get_logger
from twisted.internet import endpoints
from twisted.internet.address import IPv4Address, IPv6Address
from twisted.internet.defer import Deferred
from twisted.internet.interfaces import IListeningPort, IProtocolFactory, IStreamClientEndpoint
from twisted.internet.interfaces import IListeningPort, IProtocol, IProtocolFactory, IStreamClientEndpoint
from twisted.internet.task import LoopingCall
from twisted.protocols.tls import TLSMemoryBIOFactory, TLSMemoryBIOProtocol
from twisted.python.failure import Failure
Expand Down Expand Up @@ -593,7 +593,7 @@ def connect_to_if_not_connected(self, peer: PeerId, now: int) -> None:

def _connect_to_callback(
self,
protocol: Union[HathorProtocol, TLSMemoryBIOProtocol],
protocol: IProtocol,
peer: Optional[PeerId],
endpoint: IStreamClientEndpoint,
entrypoint: Entrypoint,
Expand All @@ -602,6 +602,7 @@ def _connect_to_callback(
if isinstance(protocol, HathorProtocol):
protocol.on_outbound_connect(entrypoint)
else:
assert isinstance(protocol, TLSMemoryBIOProtocol)
assert isinstance(protocol.wrappedProtocol, HathorProtocol)
protocol.wrappedProtocol.on_outbound_connect(entrypoint)
self.connecting_peers.pop(endpoint)
Expand Down
2 changes: 1 addition & 1 deletion hathor/p2p/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import requests
from cryptography import x509
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.backends.openssl.rsa import RSAPrivateKey
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey
from cryptography.hazmat.primitives.serialization import load_pem_private_key
from cryptography.x509 import Certificate
from cryptography.x509.oid import NameOID
Expand Down
3 changes: 2 additions & 1 deletion hathor/wallet/resources/thin_wallet/send_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ def _render_POST_stratum(self, context: _Context) -> None:

# When using stratum to solve pow, we already set timestamp and parents
stratum_deferred: Deferred[None] = Deferred()
stratum_deferred.addCallback(self._stratum_deferred_resolve, request)
# FIXME: Skipping mypy on the line below for now, as it looks like it's wrong but we don't have tests for it.
stratum_deferred.addCallback(self._stratum_deferred_resolve, request) # type: ignore

fn_timeout = partial(self._stratum_timeout, request=request, tx=tx)
stratum_deferred.addTimeout(TIMEOUT_STRATUM_RESOLVE_POW, self.manager.reactor, onTimeoutCancel=fn_timeout)
Expand Down
5 changes: 2 additions & 3 deletions hathor/wallet/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import os
from typing import Any, Optional

from cryptography.hazmat.backends.openssl.ec import _EllipticCurvePrivateKey
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import ec
from twisted.internet.interfaces import IDelayedCall
Expand Down Expand Up @@ -179,7 +178,7 @@ def generate_keys(self, count: int = 20) -> None:
# Publish to pubsub that new keys were generated
self.publish_update(HathorEvents.WALLET_KEYS_GENERATED, keys_count=count)

def get_private_key(self, address58: str) -> _EllipticCurvePrivateKey:
def get_private_key(self, address58: str) -> ec.EllipticCurvePrivateKey:
""" Get private key from the address58
:param address58: address in base58
Expand All @@ -204,7 +203,7 @@ def tokens_received(self, address58: str) -> None:
def is_locked(self):
return self.password is None

def get_input_aux_data(self, data_to_sign: bytes, private_key: _EllipticCurvePrivateKey) -> tuple[bytes, bytes]:
def get_input_aux_data(self, data_to_sign: bytes, private_key: ec.EllipticCurvePrivateKey) -> tuple[bytes, bytes]:
""" Sign the data to be used in input and get public key compressed in bytes
:param data_to_sign: Data to be signed
Expand Down
6 changes: 4 additions & 2 deletions hathor/websocket/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from autobahn.twisted.websocket import WebSocketServerProtocol
from structlog import get_logger
from twisted.python.failure import Failure

from hathor.p2p.utils import format_address
from hathor.util import json_dumpb, json_loadb, json_loads
Expand Down Expand Up @@ -243,12 +244,13 @@ def _handle_history_manual_streamer(self, message: dict[Any, Any]) -> None:
gap_limit=gap_limit,
last=last)

def _streamer_callback(self, success: bool) -> None:
def _streamer_callback(self, result: bool | Failure) -> None:
"""Callback used to identify when the streamer has ended."""
# TODO: Handle the case when `result` is Failure
assert self._history_streamer is not None
self.log.info('websocket xpub streaming has been finished',
stream_id=self._history_streamer.stream_id,
success=success,
success=result,
sent_addresses=self._history_streamer.stats_sent_addresses,
sent_vertices=self._history_streamer.stats_sent_vertices)
self._history_streamer = None
Expand Down
Loading

0 comments on commit 7f03142

Please sign in to comment.