Browse Source

lnpeer: make per-peer TaskGroup a field (as for interfaces), and use it

lnpeer (and interface) response-handling-code should not run in the
network main_taskgroup as the remote could force an exception
to be raised and that would kill the whole network instead of just the peer
dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
SomberNight 5 years ago
parent
commit
956bd3baaf
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 5
      electrum/lnpeer.py
  2. 7
      electrum/lnworker.py

5
electrum/lnpeer.py

@ -24,7 +24,7 @@ from . import bitcoin
from . import ecc
from .ecc import sig_string_from_r_and_s, get_r_and_s_from_sig_string, der_sig_from_sig_string
from . import constants
from .util import bh2u, bfh, log_exceptions, list_enabled_bits, ignore_exceptions, chunks
from .util import bh2u, bfh, log_exceptions, list_enabled_bits, ignore_exceptions, chunks, SilentTaskGroup
from .transaction import Transaction, TxOutput
from .logging import Logger
from .lnonion import (new_onion_packet, decode_onion_error, OnionFailureCode, calc_hops_data_for_payment,
@ -90,6 +90,7 @@ class Peer(Logger):
self._local_changed_events = defaultdict(asyncio.Event)
self._remote_changed_events = defaultdict(asyncio.Event)
Logger.__init__(self)
self.group = SilentTaskGroup()
def send_message(self, message_name: str, **kwargs):
assert type(message_name) is str
@ -231,7 +232,7 @@ class Peer(Logger):
@log_exceptions
@handle_disconnect
async def main_loop(self):
async with aiorpcx.TaskGroup() as group:
async with self.group as group:
await group.spawn(self._message_loop())
await group.spawn(self.query_gossip())
await group.spawn(self.process_gossip())

7
electrum/lnworker.py

@ -1102,8 +1102,11 @@ class LNWallet(LNWorker):
if not chan.should_try_to_reestablish_peer():
continue
peer = self.peers.get(chan.node_id, None)
coro = peer.reestablish_channel(chan) if peer else self.reestablish_peer_for_given_channel(chan)
await self.network.main_taskgroup.spawn(coro)
if peer:
await peer.group.spawn(peer.reestablish_channel(chan))
else:
await self.network.main_taskgroup.spawn(
self.reestablish_peer_for_given_channel(chan))
def current_feerate_per_kw(self):
from .simple_config import FEE_LN_ETA_TARGET, FEERATE_FALLBACK_STATIC_FEE, FEERATE_REGTEST_HARDCODED

Loading…
Cancel
Save