mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-16 20:34:21 +01:00
EXPERIMENTAL: pull in PR 557 (with minor fixes): range query support.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -618,8 +618,13 @@ static bool query_short_channel_ids(struct daemon *daemon,
|
||||
return false;
|
||||
}
|
||||
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
msg = towire_query_short_channel_ids(NULL, &daemon->chain_hash,
|
||||
encoded, NULL);
|
||||
#else
|
||||
msg = towire_query_short_channel_ids(NULL, &daemon->chain_hash,
|
||||
encoded);
|
||||
#endif
|
||||
queue_peer_msg(peer, take(msg));
|
||||
peer->scid_query_outstanding = true;
|
||||
peer->scid_query_was_internal = internal;
|
||||
@@ -716,12 +721,23 @@ static const u8 *handle_query_short_channel_ids(struct peer *peer, const u8 *msg
|
||||
struct bitcoin_blkid chain;
|
||||
u8 *encoded;
|
||||
struct short_channel_id *scids;
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
struct tlv_query_short_channel_ids_tlvs *tlvs
|
||||
= tlv_query_short_channel_ids_tlvs_new(tmpctx);
|
||||
|
||||
if (!fromwire_query_short_channel_ids(tmpctx, msg, &chain, &encoded,
|
||||
tlvs)) {
|
||||
return towire_errorfmt(peer, NULL,
|
||||
"Bad query_short_channel_ids w/tlvs %s",
|
||||
tal_hex(tmpctx, msg));
|
||||
}
|
||||
#else
|
||||
if (!fromwire_query_short_channel_ids(tmpctx, msg, &chain, &encoded)) {
|
||||
return towire_errorfmt(peer, NULL,
|
||||
"Bad query_short_channel_ids %s",
|
||||
tal_hex(tmpctx, msg));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!bitcoin_blkid_eq(&peer->daemon->chain_hash, &chain)) {
|
||||
status_trace("%s sent query_short_channel_ids chainhash %s",
|
||||
@@ -812,11 +828,19 @@ static void reply_channel_range(struct peer *peer,
|
||||
* - otherwise:
|
||||
* - SHOULD set `complete` to 1.
|
||||
*/
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
u8 *msg = towire_reply_channel_range(NULL,
|
||||
&peer->daemon->chain_hash,
|
||||
first_blocknum,
|
||||
number_of_blocks,
|
||||
1, encoded, NULL);
|
||||
#else
|
||||
u8 *msg = towire_reply_channel_range(NULL,
|
||||
&peer->daemon->chain_hash,
|
||||
first_blocknum,
|
||||
number_of_blocks,
|
||||
1, encoded);
|
||||
#endif
|
||||
queue_peer_msg(peer, take(msg));
|
||||
}
|
||||
|
||||
@@ -911,12 +935,25 @@ static u8 *handle_query_channel_range(struct peer *peer, const u8 *msg)
|
||||
u32 first_blocknum, number_of_blocks, tail_blocks;
|
||||
struct short_channel_id last_scid;
|
||||
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
struct tlv_query_channel_range_tlvs *tlvs
|
||||
= tlv_query_channel_range_tlvs_new(msg);
|
||||
|
||||
if (!fromwire_query_channel_range(msg, &chain_hash,
|
||||
&first_blocknum, &number_of_blocks,
|
||||
tlvs)) {
|
||||
return towire_errorfmt(peer, NULL,
|
||||
"Bad query_channel_range w/tlvs %s",
|
||||
tal_hex(tmpctx, msg));
|
||||
}
|
||||
#else
|
||||
if (!fromwire_query_channel_range(msg, &chain_hash,
|
||||
&first_blocknum, &number_of_blocks)) {
|
||||
return towire_errorfmt(peer, NULL,
|
||||
"Bad query_channel_range %s",
|
||||
tal_hex(tmpctx, msg));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* FIXME: if they ask for the wrong chain, we should not ignore it,
|
||||
* but give an empty response with the `complete` flag unset? */
|
||||
@@ -966,6 +1003,17 @@ static const u8 *handle_reply_channel_range(struct peer *peer, const u8 *msg)
|
||||
size_t n;
|
||||
unsigned long b;
|
||||
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
struct tlv_reply_channel_range_tlvs *tlvs
|
||||
= tlv_reply_channel_range_tlvs_new(tmpctx);
|
||||
if (!fromwire_reply_channel_range(tmpctx, msg, &chain, &first_blocknum,
|
||||
&number_of_blocks, &complete,
|
||||
&encoded, tlvs)) {
|
||||
return towire_errorfmt(peer, NULL,
|
||||
"Bad reply_channel_range w/tlvs %s",
|
||||
tal_hex(tmpctx, msg));
|
||||
}
|
||||
#else
|
||||
if (!fromwire_reply_channel_range(tmpctx, msg, &chain, &first_blocknum,
|
||||
&number_of_blocks, &complete,
|
||||
&encoded)) {
|
||||
@@ -973,6 +1021,7 @@ static const u8 *handle_reply_channel_range(struct peer *peer, const u8 *msg)
|
||||
"Bad reply_channel_range %s",
|
||||
tal_hex(tmpctx, msg));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!bitcoin_blkid_eq(&peer->daemon->chain_hash, &chain)) {
|
||||
return towire_errorfmt(peer, NULL,
|
||||
@@ -2639,8 +2688,15 @@ static struct io_plan *query_channel_range(struct io_conn *conn,
|
||||
|
||||
status_debug("sending query_channel_range for blocks %u+%u",
|
||||
first_blocknum, number_of_blocks);
|
||||
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
msg = towire_query_channel_range(NULL, &daemon->chain_hash,
|
||||
first_blocknum, number_of_blocks,
|
||||
NULL);
|
||||
#else
|
||||
msg = towire_query_channel_range(NULL, &daemon->chain_hash,
|
||||
first_blocknum, number_of_blocks);
|
||||
#endif
|
||||
queue_peer_msg(peer, take(msg));
|
||||
peer->range_first_blocknum = first_blocknum;
|
||||
peer->range_end_blocknum = first_blocknum + number_of_blocks;
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
--- wire/extracted_peer_wire_csv 2019-08-01 11:33:48.136457293 +0930
|
||||
+++ - 2019-08-01 11:40:21.313665504 +0930
|
||||
@@ -154,6 +168,11 @@
|
||||
msgdata,query_short_channel_ids,chain_hash,chain_hash,
|
||||
msgdata,query_short_channel_ids,len,u16,
|
||||
msgdata,query_short_channel_ids,encoded_short_ids,byte,len
|
||||
+# pr-557-tlvfixes, rebased with minor fixes
|
||||
+msgdata,query_short_channel_ids,tlvs,query_short_channel_ids_tlvs,
|
||||
+tlvtype,query_short_channel_ids_tlvs,query_flags,1
|
||||
+tlvdata,query_short_channel_ids_tlvs,query_flags,encoding_type,byte,
|
||||
+tlvdata,query_short_channel_ids_tlvs,query_flags,encoded_query_flags,byte,...
|
||||
msgtype,reply_short_channel_ids_end,262,gossip_queries
|
||||
msgdata,reply_short_channel_ids_end,chain_hash,chain_hash,
|
||||
msgdata,reply_short_channel_ids_end,complete,byte,
|
||||
@@ -161,6 +179,10 @@
|
||||
msgdata,query_channel_range,chain_hash,chain_hash,
|
||||
msgdata,query_channel_range,first_blocknum,u32,
|
||||
msgdata,query_channel_range,number_of_blocks,u32,
|
||||
+# pr-557-tlvfixes, rebased with minor fixes
|
||||
+msgdata,query_channel_range,tlvs,query_channel_range_tlvs,
|
||||
+tlvtype,query_channel_range_tlvs,query_option,1
|
||||
+tlvdata,query_channel_range_tlvs,query_option,query_option_flags,varint,
|
||||
msgtype,reply_channel_range,264,gossip_queries
|
||||
msgdata,reply_channel_range,chain_hash,chain_hash,
|
||||
msgdata,reply_channel_range,first_blocknum,u32,
|
||||
@@ -168,6 +189,20 @@
|
||||
msgdata,reply_channel_range,complete,byte,
|
||||
msgdata,reply_channel_range,len,u16,
|
||||
msgdata,reply_channel_range,encoded_short_ids,byte,len
|
||||
+# pr-557-tlvfixes, rebased with minor fixes
|
||||
+msgdata,reply_channel_range,tlvs,reply_channel_range_tlvs,
|
||||
+tlvtype,reply_channel_range_tlvs,timestamps_tlv,1
|
||||
+tlvdata,reply_channel_range_tlvs,timestamps_tlv,encoding_type,byte,
|
||||
+tlvdata,reply_channel_range_tlvs,timestamps_tlv,encoded_timestamps,byte,...
|
||||
+tlvtype,reply_channel_range_tlvs,checksums_tlv,3
|
||||
+tlvdata,reply_channel_range_tlvs,checksums_tlv,encoding_type,byte,
|
||||
+tlvdata,reply_channel_range_tlvs,checksums_tlv,encoded_checksums,byte,...
|
||||
+subtype,channel_update_timestamps
|
||||
+subtypedata,channel_update_timestamps,timestamp_node_id_1,u32,
|
||||
+subtypedata,channel_update_timestamps,timestamp_node_id_2,u32,
|
||||
+subtype,channel_update_checksums
|
||||
+subtypedata,channel_update_checksums,checksum_node_id_1,u32,
|
||||
+subtypedata,channel_update_checksums,checksum_node_id_2,u32,
|
||||
msgtype,gossip_timestamp_filter,265,gossip_queries
|
||||
msgdata,gossip_timestamp_filter,chain_hash,chain_hash,
|
||||
msgdata,gossip_timestamp_filter,first_timestamp,u32,
|
||||
|
||||
@@ -18,6 +18,18 @@ size_t bigsize_get(const u8 *p UNNEEDED, size_t max UNNEEDED, bigsize_t *val UNN
|
||||
/* Generated stub for bigsize_put */
|
||||
size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED)
|
||||
{ fprintf(stderr, "bigsize_put called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_tlvs */
|
||||
bool fromwire_tlvs(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
|
||||
const struct tlv_record_type types[] UNNEEDED,
|
||||
size_t num_types UNNEEDED,
|
||||
void *record UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_tlvs called!\n"); abort(); }
|
||||
/* Generated stub for towire_tlvs */
|
||||
void towire_tlvs(u8 **pptr UNNEEDED,
|
||||
const struct tlv_record_type types[] UNNEEDED,
|
||||
size_t num_types UNNEEDED,
|
||||
const void *record UNNEEDED)
|
||||
{ fprintf(stderr, "towire_tlvs called!\n"); abort(); }
|
||||
/* AUTOGENERATED MOCKS END */
|
||||
|
||||
/* memsetting pubkeys doesn't work */
|
||||
|
||||
Reference in New Issue
Block a user