|
@ -637,11 +637,13 @@ const u8 *handle_reply_channel_range(struct peer *peer, const u8 *msg) |
|
|
u32 first_blocknum, number_of_blocks, start, end; |
|
|
u32 first_blocknum, number_of_blocks, start, end; |
|
|
u8 *encoded; |
|
|
u8 *encoded; |
|
|
struct short_channel_id *scids; |
|
|
struct short_channel_id *scids; |
|
|
|
|
|
struct channel_update_timestamps *ts; |
|
|
size_t n; |
|
|
size_t n; |
|
|
unsigned long b; |
|
|
unsigned long b; |
|
|
void (*cb)(struct peer *peer, |
|
|
void (*cb)(struct peer *peer, |
|
|
u32 first_blocknum, u32 number_of_blocks, |
|
|
u32 first_blocknum, u32 number_of_blocks, |
|
|
const struct short_channel_id *scids, |
|
|
const struct short_channel_id *scids, |
|
|
|
|
|
const struct channel_update_timestamps *ts, |
|
|
bool complete); |
|
|
bool complete); |
|
|
struct tlv_reply_channel_range_tlvs *tlvs |
|
|
struct tlv_reply_channel_range_tlvs *tlvs |
|
|
= tlv_reply_channel_range_tlvs_new(tmpctx); |
|
|
= tlv_reply_channel_range_tlvs_new(tmpctx); |
|
@ -741,20 +743,40 @@ const u8 *handle_reply_channel_range(struct peer *peer, const u8 *msg) |
|
|
tal_resize(&peer->query_channel_scids, n + tal_count(scids)); |
|
|
tal_resize(&peer->query_channel_scids, n + tal_count(scids)); |
|
|
memcpy(peer->query_channel_scids + n, scids, tal_bytelen(scids)); |
|
|
memcpy(peer->query_channel_scids + n, scids, tal_bytelen(scids)); |
|
|
|
|
|
|
|
|
|
|
|
/* Add timestamps (if any), or zeroes */ |
|
|
|
|
|
if (tlvs->timestamps_tlv) { |
|
|
|
|
|
ts = decode_channel_update_timestamps(tlvs, |
|
|
|
|
|
tlvs->timestamps_tlv); |
|
|
|
|
|
if (!ts || tal_count(ts) != tal_count(scids)) { |
|
|
|
|
|
return towire_errorfmt(peer, NULL, |
|
|
|
|
|
"reply_channel_range %zu timestamps when %zu scids?", |
|
|
|
|
|
tal_count(ts), |
|
|
|
|
|
tal_count(scids)); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
ts = tal_arrz(tlvs, struct channel_update_timestamps, |
|
|
|
|
|
tal_count(scids)); |
|
|
|
|
|
} |
|
|
|
|
|
n = tal_count(peer->query_channel_timestamps); |
|
|
|
|
|
tal_resize(&peer->query_channel_timestamps, n + tal_count(ts)); |
|
|
|
|
|
memcpy(peer->query_channel_timestamps + n, ts, tal_bytelen(ts)); |
|
|
|
|
|
|
|
|
/* Still more to go? */ |
|
|
/* Still more to go? */ |
|
|
if (peer->range_blocks_remaining) |
|
|
if (peer->range_blocks_remaining) |
|
|
return NULL; |
|
|
return NULL; |
|
|
|
|
|
|
|
|
/* Clear these immediately in case cb want to queue more */ |
|
|
/* Clear these immediately in case cb want to queue more */ |
|
|
scids = tal_steal(tmpctx, peer->query_channel_scids); |
|
|
scids = tal_steal(tmpctx, peer->query_channel_scids); |
|
|
|
|
|
ts = tal_steal(tmpctx, peer->query_channel_timestamps); |
|
|
cb = peer->query_channel_range_cb; |
|
|
cb = peer->query_channel_range_cb; |
|
|
tal_steal(tmpctx, peer->query_channel_blocks); |
|
|
tal_steal(tmpctx, peer->query_channel_blocks); |
|
|
|
|
|
|
|
|
peer->query_channel_scids = NULL; |
|
|
peer->query_channel_scids = NULL; |
|
|
|
|
|
peer->query_channel_timestamps = NULL; |
|
|
peer->query_channel_blocks = NULL; |
|
|
peer->query_channel_blocks = NULL; |
|
|
peer->query_channel_range_cb = NULL; |
|
|
peer->query_channel_range_cb = NULL; |
|
|
|
|
|
|
|
|
cb(peer, first_blocknum, number_of_blocks, scids, complete); |
|
|
cb(peer, first_blocknum, number_of_blocks, scids, ts, complete); |
|
|
return NULL; |
|
|
return NULL; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -983,6 +1005,7 @@ bool query_channel_range(struct daemon *daemon, |
|
|
void (*cb)(struct peer *peer, |
|
|
void (*cb)(struct peer *peer, |
|
|
u32 first_blocknum, u32 number_of_blocks, |
|
|
u32 first_blocknum, u32 number_of_blocks, |
|
|
const struct short_channel_id *scids, |
|
|
const struct short_channel_id *scids, |
|
|
|
|
|
const struct channel_update_timestamps *, |
|
|
bool complete)) |
|
|
bool complete)) |
|
|
{ |
|
|
{ |
|
|
u8 *msg; |
|
|
u8 *msg; |
|
@ -1020,6 +1043,8 @@ bool query_channel_range(struct daemon *daemon, |
|
|
peer->query_channel_blocks = tal_arrz(peer, bitmap, |
|
|
peer->query_channel_blocks = tal_arrz(peer, bitmap, |
|
|
BITMAP_NWORDS(number_of_blocks)); |
|
|
BITMAP_NWORDS(number_of_blocks)); |
|
|
peer->query_channel_scids = tal_arr(peer, struct short_channel_id, 0); |
|
|
peer->query_channel_scids = tal_arr(peer, struct short_channel_id, 0); |
|
|
|
|
|
peer->query_channel_timestamps |
|
|
|
|
|
= tal_arr(peer, struct channel_update_timestamps, 0); |
|
|
peer->query_channel_range_cb = cb; |
|
|
peer->query_channel_range_cb = cb; |
|
|
|
|
|
|
|
|
return true; |
|
|
return true; |
|
|