|
|
@ -146,7 +146,7 @@ static UNNEEDED bool encoding_end_external_type(u8 **encoded, u8 *type, size_t m |
|
|
|
static bool query_short_channel_ids(struct daemon *daemon, |
|
|
|
struct peer *peer, |
|
|
|
const struct short_channel_id *scids, |
|
|
|
bool internal) |
|
|
|
void (*cb)(struct peer *peer, bool complete)) |
|
|
|
{ |
|
|
|
u8 *encoded, *msg; |
|
|
|
|
|
|
@ -189,7 +189,7 @@ static bool query_short_channel_ids(struct daemon *daemon, |
|
|
|
encoded, NULL); |
|
|
|
queue_peer_msg(peer, take(msg)); |
|
|
|
peer->scid_query_outstanding = true; |
|
|
|
peer->scid_query_was_internal = internal; |
|
|
|
peer->scid_query_cb = cb; |
|
|
|
|
|
|
|
status_debug("%s: sending query for %zu scids", |
|
|
|
type_to_string(tmpctx, struct node_id, &peer->id), |
|
|
@ -215,7 +215,7 @@ void query_unknown_channel(struct daemon *daemon, |
|
|
|
tal_arr_expand(&daemon->unknown_scids, *id); |
|
|
|
|
|
|
|
/* This is best effort: if peer is busy, we'll try next time. */ |
|
|
|
query_short_channel_ids(daemon, peer, daemon->unknown_scids, true); |
|
|
|
query_short_channel_ids(daemon, peer, daemon->unknown_scids, NULL); |
|
|
|
} |
|
|
|
|
|
|
|
/* The peer can ask about an array of short channel ids: we don't assemble the
|
|
|
@ -630,6 +630,10 @@ const u8 *handle_reply_channel_range(struct peer *peer, const u8 *msg) |
|
|
|
struct short_channel_id *scids; |
|
|
|
size_t n; |
|
|
|
unsigned long b; |
|
|
|
void (*cb)(struct peer *peer, |
|
|
|
u32 first_blocknum, u32 number_of_blocks, |
|
|
|
const struct short_channel_id *scids, |
|
|
|
bool complete); |
|
|
|
struct tlv_reply_channel_range_tlvs *tlvs |
|
|
|
= tlv_reply_channel_range_tlvs_new(tmpctx); |
|
|
|
|
|
|
@ -728,15 +732,16 @@ const u8 *handle_reply_channel_range(struct peer *peer, const u8 *msg) |
|
|
|
if (peer->range_blocks_remaining) |
|
|
|
return NULL; |
|
|
|
|
|
|
|
peer->query_channel_range_cb(peer, |
|
|
|
first_blocknum, |
|
|
|
number_of_blocks, |
|
|
|
peer->query_channel_scids, |
|
|
|
complete); |
|
|
|
/* Clear these immediately in case cb want to queue more */ |
|
|
|
scids = tal_steal(tmpctx, peer->query_channel_scids); |
|
|
|
cb = peer->query_channel_range_cb; |
|
|
|
tal_steal(tmpctx, peer->query_channel_blocks); |
|
|
|
|
|
|
|
peer->query_channel_scids = tal_free(peer->query_channel_scids); |
|
|
|
peer->query_channel_blocks = tal_free(peer->query_channel_blocks); |
|
|
|
peer->query_channel_scids = NULL; |
|
|
|
peer->query_channel_blocks = NULL; |
|
|
|
peer->query_channel_range_cb = NULL; |
|
|
|
|
|
|
|
cb(peer, first_blocknum, number_of_blocks, scids, complete); |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
|
|
|
@ -768,13 +773,8 @@ const u8 *handle_reply_short_channel_ids_end(struct peer *peer, const u8 *msg) |
|
|
|
} |
|
|
|
|
|
|
|
peer->scid_query_outstanding = false; |
|
|
|
|
|
|
|
/* If it wasn't generated by us, it's the dev interface from lightningd
|
|
|
|
*/ |
|
|
|
if (!peer->scid_query_was_internal) { |
|
|
|
msg = towire_gossip_scids_reply(msg, true, complete); |
|
|
|
daemon_conn_send(peer->daemon->master, take(msg)); |
|
|
|
} |
|
|
|
if (peer->scid_query_cb) |
|
|
|
peer->scid_query_cb(peer, complete); |
|
|
|
|
|
|
|
/* All good, no error. */ |
|
|
|
return NULL; |
|
|
@ -998,6 +998,12 @@ bool query_channel_range(struct daemon *daemon, |
|
|
|
} |
|
|
|
|
|
|
|
#if DEVELOPER |
|
|
|
static void query_scids_done(struct peer *peer, bool complete) |
|
|
|
{ |
|
|
|
const u8 *msg = towire_gossip_scids_reply(NULL, true, complete); |
|
|
|
daemon_conn_send(peer->daemon->master, take(msg)); |
|
|
|
} |
|
|
|
|
|
|
|
struct io_plan *query_scids_req(struct io_conn *conn, |
|
|
|
struct daemon *daemon, |
|
|
|
const u8 *msg) |
|
|
@ -1016,7 +1022,7 @@ struct io_plan *query_scids_req(struct io_conn *conn, |
|
|
|
daemon_conn_send(daemon->master, |
|
|
|
take(towire_gossip_scids_reply(NULL, |
|
|
|
false, false))); |
|
|
|
} else if (!query_short_channel_ids(daemon, peer, scids, false)) |
|
|
|
} else if (!query_short_channel_ids(daemon, peer, scids, query_scids_done)) |
|
|
|
daemon_conn_send(daemon->master, |
|
|
|
take(towire_gossip_scids_reply(NULL, |
|
|
|
false, false))); |
|
|
|