mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-21 14:24:09 +01:00
gossipd: add query_option_flags suport for asking query_channel_range.
This asks peers to append the timestamps or checksums: if it has gossip_query_ex support, it will, otherwise it's ignored. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
270368e50b
commit
4dcb7df83e
4 changed files with 30 additions and 16 deletions
|
@ -373,21 +373,6 @@ static void reply_channel_range(struct peer *peer,
|
|||
queue_peer_msg(peer, take(msg));
|
||||
}
|
||||
|
||||
/* BOLT #7:
|
||||
*
|
||||
* `query_option_flags` is a bitfield represented as a minimally-encoded varint.
|
||||
* Bits have the following meaning:
|
||||
*
|
||||
* | Bit Position | Meaning |
|
||||
* | ------------- | ----------------------- |
|
||||
* | 0 | Sender wants timestamps |
|
||||
* | 1 | Sender wants checksums |
|
||||
*/
|
||||
enum query_option_flags {
|
||||
QUERY_ADD_TIMESTAMPS = 0x1,
|
||||
QUERY_ADD_CHECKSUMS = 0x2,
|
||||
};
|
||||
|
||||
/* BOLT #7:
|
||||
*
|
||||
* The checksum of a `channel_update` is the CRC32C checksum as specified in
|
||||
|
@ -994,13 +979,16 @@ void maybe_send_query_responses(struct peer *peer)
|
|||
bool query_channel_range(struct daemon *daemon,
|
||||
struct peer *peer,
|
||||
u32 first_blocknum, u32 number_of_blocks,
|
||||
enum query_option_flags qflags,
|
||||
void (*cb)(struct peer *peer,
|
||||
u32 first_blocknum, u32 number_of_blocks,
|
||||
const struct short_channel_id *scids,
|
||||
bool complete))
|
||||
{
|
||||
u8 *msg;
|
||||
struct tlv_query_channel_range_tlvs *tlvs;
|
||||
|
||||
assert((qflags & ~(QUERY_ADD_TIMESTAMPS|QUERY_ADD_CHECKSUMS)) == 0);
|
||||
assert(peer->gossip_queries_feature);
|
||||
assert(!peer->query_channel_blocks);
|
||||
assert(!peer->query_channel_range_cb);
|
||||
|
@ -1012,12 +1000,19 @@ bool query_channel_range(struct daemon *daemon,
|
|||
return false;
|
||||
}
|
||||
|
||||
if (qflags) {
|
||||
tlvs = tlv_query_channel_range_tlvs_new(tmpctx);
|
||||
tlvs->query_option
|
||||
= tal(tlvs, struct tlv_query_channel_range_tlvs_query_option);
|
||||
tlvs->query_option->query_option_flags = qflags;
|
||||
} else
|
||||
tlvs = NULL;
|
||||
status_debug("sending query_channel_range for blocks %u+%u",
|
||||
first_blocknum, number_of_blocks);
|
||||
|
||||
msg = towire_query_channel_range(NULL, &daemon->chain_hash,
|
||||
first_blocknum, number_of_blocks,
|
||||
NULL);
|
||||
tlvs);
|
||||
queue_peer_msg(peer, take(msg));
|
||||
peer->range_first_blocknum = first_blocknum;
|
||||
peer->range_end_blocknum = first_blocknum + number_of_blocks;
|
||||
|
|
|
@ -18,11 +18,27 @@ const u8 *handle_reply_channel_range(struct peer *peer, const u8 *msg);
|
|||
/* This called when the peer is idle. */
|
||||
void maybe_send_query_responses(struct peer *peer);
|
||||
|
||||
/* BOLT #7:
|
||||
*
|
||||
* `query_option_flags` is a bitfield represented as a minimally-encoded varint.
|
||||
* Bits have the following meaning:
|
||||
*
|
||||
* | Bit Position | Meaning |
|
||||
* | ------------- | ----------------------- |
|
||||
* | 0 | Sender wants timestamps |
|
||||
* | 1 | Sender wants checksums |
|
||||
*/
|
||||
enum query_option_flags {
|
||||
QUERY_ADD_TIMESTAMPS = 0x1,
|
||||
QUERY_ADD_CHECKSUMS = 0x2,
|
||||
};
|
||||
|
||||
/* Ask this peer for a range of scids. Must support it, and not already
|
||||
* have a query pending. */
|
||||
bool query_channel_range(struct daemon *daemon,
|
||||
struct peer *peer,
|
||||
u32 first_blocknum, u32 number_of_blocks,
|
||||
enum query_option_flags qflags,
|
||||
void (*cb)(struct peer *peer,
|
||||
u32 first_blocknum, u32 number_of_blocks,
|
||||
const struct short_channel_id *scids,
|
||||
|
|
|
@ -503,6 +503,7 @@ static void process_scid_probe(struct peer *peer,
|
|||
|
||||
query_channel_range(seeker->daemon, peer,
|
||||
first_blocknum, number_of_blocks,
|
||||
QUERY_ADD_TIMESTAMPS,
|
||||
process_scid_probe);
|
||||
return;
|
||||
}
|
||||
|
@ -537,6 +538,7 @@ static void peer_gossip_probe_scids(struct seeker *seeker)
|
|||
query_channel_range(seeker->daemon, peer,
|
||||
seeker->scid_probe_start,
|
||||
seeker->scid_probe_end - seeker->scid_probe_start + 1,
|
||||
QUERY_ADD_TIMESTAMPS,
|
||||
process_scid_probe);
|
||||
set_state(seeker, PROBING_SCIDS);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ struct oneshot *new_reltimer_(struct timers *timers UNNEEDED,
|
|||
bool query_channel_range(struct daemon *daemon UNNEEDED,
|
||||
struct peer *peer UNNEEDED,
|
||||
u32 first_blocknum UNNEEDED, u32 number_of_blocks UNNEEDED,
|
||||
enum query_option_flags qflags UNNEEDED,
|
||||
void (*cb)(struct peer *peer UNNEEDED,
|
||||
u32 first_blocknum UNNEEDED, u32 number_of_blocks UNNEEDED,
|
||||
const struct short_channel_id *scids UNNEEDED,
|
||||
|
|
Loading…
Add table
Reference in a new issue