Require gossip_queries in LNWallet (follow-up f83d2d9fee)
- workaround lnd bug https://github.com/lightningnetwork/lnd/issues/3651 - also reduces bandwidth usage
This commit is contained in:
@@ -256,6 +256,8 @@ class Peer(Logger):
|
||||
self.gossip_queue.put_nowait(('channel_update', payload))
|
||||
|
||||
def maybe_save_remote_update(self, payload):
|
||||
if not self.channels:
|
||||
return
|
||||
for chan in self.channels.values():
|
||||
if chan.short_channel_id == payload['short_channel_id']:
|
||||
chan.set_remote_update(payload['raw'])
|
||||
@@ -265,7 +267,14 @@ class Peer(Logger):
|
||||
# Save (some bounded number of) orphan channel updates for later
|
||||
# as it might be for our own direct channel with this peer
|
||||
# (and we might not yet know the short channel id for that)
|
||||
# Background: this code is here to deal with a bug in LND,
|
||||
# see https://github.com/lightningnetwork/lnd/issues/3651
|
||||
# and https://github.com/lightningnetwork/lightning-rfc/pull/657
|
||||
# This code assumes gossip_queries is set. BOLT7: "if the
|
||||
# gossip_queries feature is negotiated, [a node] MUST NOT
|
||||
# send gossip it did not generate itself"
|
||||
short_channel_id = ShortChannelID(payload['short_channel_id'])
|
||||
self.logger.info(f'received orphan channel update {short_channel_id}')
|
||||
self.orphan_channel_updates[short_channel_id] = payload
|
||||
while len(self.orphan_channel_updates) > 25:
|
||||
self.orphan_channel_updates.popitem(last=False)
|
||||
|
||||
@@ -554,6 +554,9 @@ class LNWallet(LNWorker):
|
||||
self.lnrater: LNRater = None
|
||||
self.features |= LnFeatures.OPTION_DATA_LOSS_PROTECT_REQ
|
||||
self.features |= LnFeatures.OPTION_STATIC_REMOTEKEY_REQ
|
||||
# we do not want to receive unrequested gossip (see lnpeer.maybe_save_remote_update)
|
||||
self.features |= LnFeatures.GOSSIP_QUERIES_REQ
|
||||
|
||||
self.payments = self.db.get_dict('lightning_payments') # RHASH -> amount, direction, is_paid # FIXME amt should be msat
|
||||
self.preimages = self.db.get_dict('lightning_preimages') # RHASH -> preimage
|
||||
# note: this sweep_address is only used as fallback; as it might result in address-reuse
|
||||
|
||||
Reference in New Issue
Block a user