Do not route through channels for which we did not receive

both updates, because this often means one of the nodes is
offline.
This commit is contained in:
ThomasV 2019-07-13 08:46:17 +02:00
parent 30e942bead
commit b55f9e9e6a
3 changed files with 20 additions and 3 deletions

View file

@ -527,6 +527,16 @@ class ChannelDB(SqlDB):
self._channels_for_node[channel_info.node2_id].add(channel_info.short_channel_id)
self.logger.info(f'load data {len(self._channels)} {len(self._policies)} {len(self._channels_for_node)}')
self.update_counts()
self.count_incomplete_channels()
def count_incomplete_channels(self):
out = set()
for short_channel_id, ci in self._channels.items():
p1 = self.get_policy_for_node(short_channel_id, ci.node1_id)
p2 = self.get_policy_for_node(short_channel_id, ci.node2_id)
if p1 is None or p2 is not None:
out.add(short_channel_id)
self.logger.info(f'semi-orphaned: {len(out)}')
def get_policy_for_node(self, short_channel_id: bytes, node_id: bytes) -> Optional['Policy']:
return self._policies.get((node_id, short_channel_id))

View file

@ -1019,8 +1019,7 @@ class Peer(Logger):
except IndexError:
self.logger.info("payment destination reported error")
else:
self.logger.info(f'blacklisting channel {bh2u(short_chan_id)}')
self.network.path_finder.blacklist.add(short_chan_id)
self.network.path_finder.add_to_blacklist(short_chan_id)
def maybe_send_commitment(self, chan: Channel):
ctn_to_sign = chan.get_current_ctn(REMOTE) + 1

View file

@ -129,6 +129,10 @@ class LNPathFinder(Logger):
self.channel_db = channel_db
self.blacklist = set()
def add_to_blacklist(self, short_channel_id):
self.logger.info(f'blacklisting channel {bh2u(short_channel_id)}')
self.blacklist.add(short_channel_id)
def _edge_cost(self, short_channel_id: bytes, start_node: bytes, end_node: bytes,
payment_amt_msat: int, ignore_costs=False) -> Tuple[float, int]:
"""Heuristic cost of going through a channel.
@ -140,7 +144,11 @@ class LNPathFinder(Logger):
channel_policy = self.channel_db.get_policy_for_node(short_channel_id, start_node)
if channel_policy is None:
return float('inf'), 0
if channel_policy.is_disabled(): return float('inf'), 0
# channels that did not publish both policies often return temporary channel failure
if self.channel_db.get_policy_for_node(short_channel_id, end_node) is None:
return float('inf'), 0
if channel_policy.is_disabled():
return float('inf'), 0
route_edge = RouteEdge.from_channel_policy(channel_policy, short_channel_id, end_node)
if payment_amt_msat < channel_policy.htlc_minimum_msat:
return float('inf'), 0 # payment amount too little