Browse Source

lnworker: fix path_finder access

patch-4
bitromortac 4 years ago
parent
commit
4cb0b99996
No known key found for this signature in database GPG Key ID: 1965063FC13BEBE2
  1. 6
      electrum/commands.py
  2. 8
      electrum/lnworker.py
  3. 2
      electrum/network.py

6
electrum/commands.py

@ -1092,11 +1092,13 @@ class Commands:
@command('n') @command('n')
async def clear_ln_blacklist(self): async def clear_ln_blacklist(self):
self.network.path_finder.liquidity_hints.clear_blacklist() if self.network.path_finder:
self.network.path_finder.liquidity_hints.clear_blacklist()
@command('n') @command('n')
async def reset_liquidity_hints(self): async def reset_liquidity_hints(self):
self.network.path_finder.liquidity_hints.reset_liquidity_hints() if self.network.path_finder:
self.network.path_finder.liquidity_hints.reset_liquidity_hints()
@command('w') @command('w')
async def list_invoices(self, wallet: Abstract_Wallet = None): async def list_invoices(self, wallet: Abstract_Wallet = None):

8
electrum/lnworker.py

@ -1214,7 +1214,8 @@ class LNWallet(LNWorker):
# even in the case of success, we report channels of the # even in the case of success, we report channels of the
# route as being able to send the same amount in the future, # route as being able to send the same amount in the future,
# as we assume to not know the capacity # as we assume to not know the capacity
self.network.path_finder.update_liquidity_hints(htlc_log.route, htlc_log.amount_msat) if self.network.path_finder:
self.network.path_finder.update_liquidity_hints(htlc_log.route, htlc_log.amount_msat)
return return
# htlc failed # htlc failed
if len(log) >= attempts: if len(log) >= attempts:
@ -1309,8 +1310,6 @@ class LNWallet(LNWorker):
raise PaymentFailure(failure_msg.code_name()) raise PaymentFailure(failure_msg.code_name())
try: try:
fallback_channel = route[sender_idx + 1].short_channel_id fallback_channel = route[sender_idx + 1].short_channel_id
node_from = route[sender_idx].start_node
node_to = route[sender_idx].end_node
except IndexError: except IndexError:
raise PaymentFailure(f'payment destination reported error: {failure_msg.code_name()}') from None raise PaymentFailure(f'payment destination reported error: {failure_msg.code_name()}') from None
@ -1325,7 +1324,7 @@ class LNWallet(LNWorker):
if payload is None: if payload is None:
self.logger.info(f'could not decode channel_update for failed htlc: ' self.logger.info(f'could not decode channel_update for failed htlc: '
f'{channel_update_as_received.hex()}') f'{channel_update_as_received.hex()}')
self.network.path_finder.channel_blacklist.add(fallback_channel) self.network.path_finder.liquidity_hints.add_to_blacklist(fallback_channel)
else: else:
# apply the channel update or get blacklisted # apply the channel update or get blacklisted
blacklist, update = self._handle_chanupd_from_failed_htlc( blacklist, update = self._handle_chanupd_from_failed_htlc(
@ -1345,7 +1344,6 @@ class LNWallet(LNWorker):
# if we can't decide on some action, we are stuck # if we can't decide on some action, we are stuck
if not (blacklist or update): if not (blacklist or update):
raise PaymentFailure(failure_msg.code_name()) raise PaymentFailure(failure_msg.code_name())
# for errors that do not include a channel update # for errors that do not include a channel update
else: else:
self.network.path_finder.liquidity_hints.add_to_blacklist(fallback_channel) self.network.path_finder.liquidity_hints.add_to_blacklist(fallback_channel)

2
electrum/network.py

@ -65,6 +65,7 @@ from .logging import get_logger, Logger
if TYPE_CHECKING: if TYPE_CHECKING:
from .channel_db import ChannelDB from .channel_db import ChannelDB
from .lnrouter import LNPathFinder
from .lnworker import LNGossip from .lnworker import LNGossip
from .lnwatcher import WatchTower from .lnwatcher import WatchTower
from .daemon import Daemon from .daemon import Daemon
@ -256,6 +257,7 @@ class Network(Logger, NetworkRetryManager[ServerAddr]):
channel_db: Optional['ChannelDB'] = None channel_db: Optional['ChannelDB'] = None
lngossip: Optional['LNGossip'] = None lngossip: Optional['LNGossip'] = None
local_watchtower: Optional['WatchTower'] = None local_watchtower: Optional['WatchTower'] = None
path_finder: Optional['LNPathFinder'] = None
def __init__(self, config: SimpleConfig, *, daemon: 'Daemon' = None): def __init__(self, config: SimpleConfig, *, daemon: 'Daemon' = None):
global _INSTANCE global _INSTANCE

Loading…
Cancel
Save