gossipd: work around LND reply_channel_range.

We've been sending them errors for invalid replies; instead, this works
around it.

Changelog-Added: Workaround LND's reply_channel_range issues instead of sending error.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2019-11-15 15:46:52 +10:30 committed by Christian Decker
parent 14a5584b50
commit 6e433e0108

View File

@ -720,6 +720,16 @@ const u8 *handle_reply_channel_range(struct peer *peer, const u8 *msg)
if (end > peer->range_end_blocknum) if (end > peer->range_end_blocknum)
end = peer->range_end_blocknum; end = peer->range_end_blocknum;
/* LND mis-implemented the spec. If they have multiple replies, set
* each one to the *whole* range, with complete=0 except the last.
* Try to accomodate that (pretend we make no progress until the
* end)! */
if (first_blocknum == peer->range_first_blocknum
&& first_blocknum + number_of_blocks == peer->range_end_blocknum
&& !complete
&& tal_bytelen(msg) == 64046) {
status_debug("LND reply_channel_range detected: futzing");
} else {
/* We keep a bitmap of what blocks have been covered by replies: bit 0 /* We keep a bitmap of what blocks have been covered by replies: bit 0
* represents block peer->range_first_blocknum */ * represents block peer->range_first_blocknum */
b = bitmap_ffs(peer->query_channel_blocks, b = bitmap_ffs(peer->query_channel_blocks,
@ -737,6 +747,7 @@ const u8 *handle_reply_channel_range(struct peer *peer, const u8 *msg)
start - peer->range_first_blocknum, start - peer->range_first_blocknum,
end - peer->range_first_blocknum); end - peer->range_first_blocknum);
peer->range_blocks_remaining -= end - start; peer->range_blocks_remaining -= end - start;
}
/* Add scids */ /* Add scids */
n = tal_count(peer->query_channel_scids); n = tal_count(peer->query_channel_scids);