mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 09:34:24 +01:00
gossipd: hand (any) timestamps through to callback for query_channel_range.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
neil saitug
parent
4dcb7df83e
commit
1f2a03f019
@@ -637,11 +637,13 @@ const u8 *handle_reply_channel_range(struct peer *peer, const u8 *msg)
|
||||
u32 first_blocknum, number_of_blocks, start, end;
|
||||
u8 *encoded;
|
||||
struct short_channel_id *scids;
|
||||
struct channel_update_timestamps *ts;
|
||||
size_t n;
|
||||
unsigned long b;
|
||||
void (*cb)(struct peer *peer,
|
||||
u32 first_blocknum, u32 number_of_blocks,
|
||||
const struct short_channel_id *scids,
|
||||
const struct channel_update_timestamps *ts,
|
||||
bool complete);
|
||||
struct tlv_reply_channel_range_tlvs *tlvs
|
||||
= 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));
|
||||
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? */
|
||||
if (peer->range_blocks_remaining)
|
||||
return NULL;
|
||||
|
||||
/* Clear these immediately in case cb want to queue more */
|
||||
scids = tal_steal(tmpctx, peer->query_channel_scids);
|
||||
ts = tal_steal(tmpctx, peer->query_channel_timestamps);
|
||||
cb = peer->query_channel_range_cb;
|
||||
tal_steal(tmpctx, peer->query_channel_blocks);
|
||||
|
||||
peer->query_channel_scids = NULL;
|
||||
peer->query_channel_timestamps = NULL;
|
||||
peer->query_channel_blocks = 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;
|
||||
}
|
||||
|
||||
@@ -983,6 +1005,7 @@ bool query_channel_range(struct daemon *daemon,
|
||||
void (*cb)(struct peer *peer,
|
||||
u32 first_blocknum, u32 number_of_blocks,
|
||||
const struct short_channel_id *scids,
|
||||
const struct channel_update_timestamps *,
|
||||
bool complete))
|
||||
{
|
||||
u8 *msg;
|
||||
@@ -1020,6 +1043,8 @@ bool query_channel_range(struct daemon *daemon,
|
||||
peer->query_channel_blocks = tal_arrz(peer, bitmap,
|
||||
BITMAP_NWORDS(number_of_blocks));
|
||||
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;
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user