2019-09-22 07:53:42 +02:00
|
|
|
#ifndef LIGHTNING_GOSSIPD_QUERIES_H
|
|
|
|
#define LIGHTNING_GOSSIPD_QUERIES_H
|
|
|
|
#include "config.h"
|
|
|
|
#include <ccan/short_types/short_types.h>
|
|
|
|
|
2019-10-08 03:23:24 +02:00
|
|
|
struct channel_update_timestamps;
|
2019-09-22 07:53:42 +02:00
|
|
|
struct daemon;
|
|
|
|
struct io_conn;
|
|
|
|
struct peer;
|
|
|
|
struct short_channel_id;
|
|
|
|
|
|
|
|
/* Various handlers when peer fwds a gossip query msg: return is NULL or
|
|
|
|
* error packet. */
|
|
|
|
const u8 *handle_query_short_channel_ids(struct peer *peer, const u8 *msg);
|
|
|
|
const u8 *handle_reply_short_channel_ids_end(struct peer *peer, const u8 *msg);
|
|
|
|
const u8 *handle_query_channel_range(struct peer *peer, const u8 *msg);
|
|
|
|
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);
|
|
|
|
|
2019-10-08 03:22:24 +02:00
|
|
|
/* BOLT #7:
|
|
|
|
*
|
2020-06-22 07:06:03 +02:00
|
|
|
* `query_option_flags` is a bitfield represented as a minimally-encoded bigsize.
|
2019-10-08 03:22:24 +02:00
|
|
|
* 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,
|
|
|
|
};
|
|
|
|
|
2019-09-30 06:57:12 +02:00
|
|
|
/* 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,
|
2019-10-08 03:22:24 +02:00
|
|
|
enum query_option_flags qflags,
|
2019-09-30 06:57:12 +02:00
|
|
|
void (*cb)(struct peer *peer,
|
|
|
|
u32 first_blocknum, u32 number_of_blocks,
|
2021-02-23 02:42:53 +01:00
|
|
|
const struct range_query_reply *replies));
|
2019-09-30 06:57:12 +02:00
|
|
|
|
2019-10-08 03:21:24 +02:00
|
|
|
/* Ask this peer for info about an array of scids, with optional query_flags */
|
2019-10-08 03:15:24 +02:00
|
|
|
bool query_short_channel_ids(struct daemon *daemon,
|
|
|
|
struct peer *peer,
|
|
|
|
const struct short_channel_id *scids,
|
2019-10-08 03:21:24 +02:00
|
|
|
const u8 *query_flags,
|
2019-10-08 03:15:24 +02:00
|
|
|
void (*cb)(struct peer *peer, bool complete));
|
|
|
|
|
2019-09-22 07:53:42 +02:00
|
|
|
#if DEVELOPER
|
|
|
|
struct io_plan *query_scids_req(struct io_conn *conn,
|
|
|
|
struct daemon *daemon,
|
|
|
|
const u8 *msg);
|
|
|
|
|
2019-09-30 06:57:12 +02:00
|
|
|
struct io_plan *dev_query_channel_range(struct io_conn *conn,
|
|
|
|
struct daemon *daemon,
|
|
|
|
const u8 *msg);
|
2019-09-22 07:53:42 +02:00
|
|
|
|
|
|
|
/* This is a testing hack to allow us to artificially lower the maximum bytes
|
|
|
|
* of short_channel_ids we'll encode, using dev_set_max_scids_encode_size. */
|
2021-12-29 04:26:43 +01:00
|
|
|
void dev_set_max_scids_encode_size(struct daemon *daemon, const u8 *msg);
|
2019-09-22 07:53:42 +02:00
|
|
|
#endif /* DEVELOPER */
|
|
|
|
|
|
|
|
#endif /* LIGHTNING_GOSSIPD_QUERIES_H */
|