gossip_store: change format so we store raw messages.
Save some overhead, plus gets us ready for giving subdaemons direct store access. This is the first time we *upgrade* the gossip_store, rather than just discarding. The downside is that we need to add an extra message after each channel_announcement, containing the channel capacity. After: store_load_msec:28337-30288(28975+/-7.4e+02) vsz_kb:582304-582316(582306+/-4.8) store_rewrite_sec:11.240000-11.800000(11.55+/-0.21) listnodes_sec:1.800000-1.880000(1.84+/-0.028) listchannels_sec:22.690000-26.260000(23.878+/-1.3) routing_sec:2.280000-9.570000(6.842+/-2.8) peer_write_all_sec:48.160000-51.480000(49.608+/-1.1) Differences: -vsz_kb:582320 +vsz_kb:582316 -listnodes_sec:2.100000-2.170000(2.118+/-0.026) +listnodes_sec:1.800000-1.880000(1.84+/-0.028) -peer_write_all_sec:51.600000-52.550000(52.188+/-0.34) +peer_write_all_sec:48.160000-51.480000(49.608+/-1.1) Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -49,6 +49,18 @@ static struct scidsat *load_csv_file(FILE *scidf)
|
||||
return scidsats;
|
||||
}
|
||||
|
||||
static void write_outmsg(int outfd, const u8 *outmsg)
|
||||
{
|
||||
beint32_t hdr[2];
|
||||
|
||||
hdr[0] = cpu_to_be32(tal_count(outmsg));
|
||||
hdr[1] = cpu_to_be32(crc32c(0, outmsg, tal_count(outmsg)));
|
||||
|
||||
if (!write_all(outfd, hdr, sizeof(hdr))
|
||||
|| !write_all(outfd, outmsg, tal_count(outmsg)))
|
||||
err(1, "Writing output");
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
u8 version;
|
||||
@@ -116,9 +128,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
while (read_all(infd, &be_inlen, sizeof(be_inlen))) {
|
||||
u32 msglen = be16_to_cpu(be_inlen);
|
||||
u8 *inmsg = tal_arr(NULL, u8, msglen), *outmsg;
|
||||
beint32_t be_outlen;
|
||||
beint32_t becsum;
|
||||
u8 *inmsg = tal_arr(NULL, u8, msglen);
|
||||
|
||||
if (!read_all(infd, inmsg, msglen))
|
||||
err(1, "Only read partial message");
|
||||
@@ -153,35 +163,31 @@ int main(int argc, char *argv[])
|
||||
sat = scidsats[scidi].sat;
|
||||
scidi++;
|
||||
}
|
||||
outmsg = towire_gossip_store_channel_announcement(inmsg, inmsg, sat);
|
||||
/* First write announce */
|
||||
write_outmsg(outfd, inmsg);
|
||||
channels += 1;
|
||||
/* Now write amount */
|
||||
write_outmsg(outfd,
|
||||
towire_gossip_store_channel_amount(inmsg,
|
||||
sat));
|
||||
break;
|
||||
|
||||
case WIRE_CHANNEL_UPDATE:
|
||||
outmsg = towire_gossip_store_channel_update(inmsg, inmsg);
|
||||
write_outmsg(outfd, inmsg);
|
||||
updates += 1;
|
||||
break;
|
||||
|
||||
case WIRE_NODE_ANNOUNCEMENT:
|
||||
outmsg = towire_gossip_store_node_announcement(inmsg, inmsg);
|
||||
write_outmsg(outfd, inmsg);
|
||||
nodes += 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
warnx("Unknown message %u (%s)", fromwire_peektype(inmsg),
|
||||
wire_type_name(fromwire_peektype(inmsg)));
|
||||
tal_free(inmsg);
|
||||
continue;
|
||||
}
|
||||
if (verbose)
|
||||
fprintf(stderr, "%s->%s\n",
|
||||
wire_type_name(fromwire_peektype(inmsg)),
|
||||
gossip_store_type_name(fromwire_peektype(outmsg)));
|
||||
|
||||
becsum = cpu_to_be32(crc32c(0, outmsg, tal_count(outmsg)));
|
||||
be_outlen = cpu_to_be32(tal_count(outmsg));
|
||||
if (!write_all(outfd, &be_outlen, sizeof(be_outlen))
|
||||
|| !write_all(outfd, &becsum, sizeof(becsum))
|
||||
|| !write_all(outfd, outmsg, tal_count(outmsg))) {
|
||||
exit(1);
|
||||
}
|
||||
tal_free(inmsg);
|
||||
if (--max == 0)
|
||||
break;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <common/type_to_string.h>
|
||||
#include <common/utils.h>
|
||||
#include <fcntl.h>
|
||||
#include <gossipd/gen_gossip_peerd_wire.h>
|
||||
#include <gossipd/gen_gossip_store.h>
|
||||
#include <gossipd/gossip_store.h>
|
||||
#include <inttypes.h>
|
||||
@@ -10,6 +11,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <wire/gen_peer_wire.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -42,7 +44,6 @@ int main(int argc, char *argv[])
|
||||
read(fd, &becsum, sizeof(becsum)) == sizeof(becsum)) {
|
||||
struct amount_sat sat;
|
||||
struct short_channel_id scid;
|
||||
u8 *gossip_msg;
|
||||
u32 msglen = be32_to_cpu(belen);
|
||||
u8 *msg = tal_arr(NULL, u8, msglen);
|
||||
|
||||
@@ -52,28 +53,21 @@ int main(int argc, char *argv[])
|
||||
if (be32_to_cpu(becsum) != crc32c(0, msg, msglen))
|
||||
warnx("Checksum verification failed");
|
||||
|
||||
if (fromwire_gossip_store_channel_announcement(msg, msg,
|
||||
&gossip_msg,
|
||||
&sat)) {
|
||||
printf("channel_announce for %s: %s\n",
|
||||
type_to_string(tmpctx, struct amount_sat, &sat),
|
||||
tal_hex(msg, gossip_msg));
|
||||
} else if (fromwire_gossip_store_channel_update(msg, msg,
|
||||
&gossip_msg)) {
|
||||
printf("channel_update: %s\n",
|
||||
tal_hex(msg, gossip_msg));
|
||||
} else if (fromwire_gossip_store_node_announcement(msg, msg,
|
||||
&gossip_msg)) {
|
||||
printf("node_announcement: %s\n",
|
||||
tal_hex(msg, gossip_msg));
|
||||
if (fromwire_gossip_store_channel_amount(msg, &sat)) {
|
||||
printf("channel_amount: %s\n",
|
||||
type_to_string(tmpctx, struct amount_sat, &sat));
|
||||
} else if (fromwire_peektype(msg) == WIRE_CHANNEL_ANNOUNCEMENT) {
|
||||
printf("channel_announcement: %s\n", tal_hex(msg, msg));
|
||||
} else if (fromwire_peektype(msg) == WIRE_CHANNEL_UPDATE) {
|
||||
printf("channel_update: %s\n", tal_hex(msg, msg));
|
||||
} else if (fromwire_peektype(msg) == WIRE_NODE_ANNOUNCEMENT) {
|
||||
printf("node_announcement: %s\n", tal_hex(msg, msg));
|
||||
} else if (fromwire_peektype(msg) == WIRE_GOSSIPD_LOCAL_ADD_CHANNEL) {
|
||||
printf("local_add_channel: %s\n", tal_hex(msg, msg));
|
||||
} else if (fromwire_gossip_store_channel_delete(msg, &scid)) {
|
||||
printf("channel_delete: %s\n",
|
||||
type_to_string(msg, struct short_channel_id,
|
||||
&scid));
|
||||
} else if (fromwire_gossip_store_local_add_channel(
|
||||
msg, msg, &gossip_msg)) {
|
||||
printf("local_add_channel: %s\n",
|
||||
tal_hex(msg, gossip_msg));
|
||||
} else {
|
||||
warnx("Unknown message %u", fromwire_peektype(msg));
|
||||
}
|
||||
|
||||
@@ -46,6 +46,122 @@ static void gossip_store_destroy(struct gossip_store *gs)
|
||||
close(gs->fd);
|
||||
}
|
||||
|
||||
static bool append_msg(int fd, const u8 *msg, u64 *len)
|
||||
{
|
||||
beint32_t hdr[2];
|
||||
u32 msglen;
|
||||
|
||||
msglen = tal_count(msg);
|
||||
hdr[0] = cpu_to_be32(msglen);
|
||||
hdr[1] = cpu_to_be32(crc32c(0, msg, msglen));
|
||||
|
||||
if (len)
|
||||
*len += sizeof(hdr) + msglen;
|
||||
|
||||
return (write(fd, hdr, sizeof(hdr)) == sizeof(hdr) &&
|
||||
write(fd, msg, msglen) == msglen);
|
||||
}
|
||||
|
||||
static bool upgrade_gs(struct gossip_store *gs)
|
||||
{
|
||||
beint32_t hdr[2];
|
||||
size_t off = gs->len;
|
||||
int newfd;
|
||||
const u8 newversion = GOSSIP_STORE_VERSION;
|
||||
|
||||
if (gs->version != 3)
|
||||
return false;
|
||||
|
||||
newfd = open(GOSSIP_STORE_TEMP_FILENAME,
|
||||
O_RDWR|O_APPEND|O_CREAT|O_TRUNC,
|
||||
0600);
|
||||
if (newfd < 0) {
|
||||
status_broken("gossip_store: can't create temp %s: %s",
|
||||
GOSSIP_STORE_TEMP_FILENAME, strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!write_all(newfd, &newversion, sizeof(newversion))) {
|
||||
status_broken("gossip_store: can't write header to %s: %s",
|
||||
GOSSIP_STORE_TEMP_FILENAME, strerror(errno));
|
||||
close(newfd);
|
||||
return false;
|
||||
}
|
||||
|
||||
while (pread(gs->fd, hdr, sizeof(hdr), off) == sizeof(hdr)) {
|
||||
u32 msglen, checksum;
|
||||
u8 *msg, *gossip_msg;
|
||||
struct amount_sat satoshis;
|
||||
|
||||
msglen = be32_to_cpu(hdr[0]);
|
||||
checksum = be32_to_cpu(hdr[1]);
|
||||
msg = tal_arr(tmpctx, u8, msglen);
|
||||
|
||||
if (pread(gs->fd, msg, msglen, off+sizeof(hdr)) != msglen) {
|
||||
status_unusual("gossip_store: truncated file @%zu?",
|
||||
off + sizeof(hdr));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (checksum != crc32c(0, msg, msglen)) {
|
||||
status_unusual("gossip_store: checksum failed");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* These need to be appended with channel size */
|
||||
if (fromwire_gossip_store_v3_channel_announcement(msg, msg,
|
||||
&gossip_msg,
|
||||
&satoshis)) {
|
||||
u8 *amt = towire_gossip_store_channel_amount(msg,
|
||||
satoshis);
|
||||
if (!append_msg(newfd, gossip_msg, NULL))
|
||||
goto write_fail;
|
||||
if (!append_msg(newfd, amt, NULL))
|
||||
goto write_fail;
|
||||
/* These are extracted and copied verbatim */
|
||||
} else if (fromwire_gossip_store_v3_channel_update(msg, msg,
|
||||
&gossip_msg)
|
||||
|| fromwire_gossip_store_v3_node_announcement(msg,
|
||||
msg,
|
||||
&gossip_msg)
|
||||
|| fromwire_gossip_store_v3_local_add_channel(msg,
|
||||
msg,
|
||||
&gossip_msg)) {
|
||||
if (!append_msg(newfd, gossip_msg, NULL))
|
||||
goto write_fail;
|
||||
} else {
|
||||
/* Just copy into new store. */
|
||||
if (write(newfd, hdr, sizeof(hdr)) != sizeof(hdr)
|
||||
|| write(newfd, msg, tal_bytelen(msg)) !=
|
||||
tal_bytelen(msg))
|
||||
goto write_fail;
|
||||
}
|
||||
off += sizeof(hdr) + msglen;
|
||||
clean_tmpctx();
|
||||
}
|
||||
|
||||
if (rename(GOSSIP_STORE_TEMP_FILENAME, GOSSIP_STORE_FILENAME) == -1) {
|
||||
status_broken(
|
||||
"Error swapping compacted gossip_store into place: %s",
|
||||
strerror(errno));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
status_info("Upgraded gossip_store from version %u to %u",
|
||||
gs->version, newversion);
|
||||
close(gs->fd);
|
||||
gs->fd = newfd;
|
||||
gs->version = newversion;
|
||||
return true;
|
||||
|
||||
write_fail:
|
||||
status_unusual("gossip_store: write failed for upgrade: %s",
|
||||
strerror(errno));
|
||||
fail:
|
||||
close(newfd);
|
||||
return false;
|
||||
}
|
||||
|
||||
struct gossip_store *gossip_store_new(struct routing_state *rstate)
|
||||
{
|
||||
struct gossip_store *gs = tal(rstate, struct gossip_store);
|
||||
@@ -66,6 +182,9 @@ struct gossip_store *gossip_store_new(struct routing_state *rstate)
|
||||
if (gs->version == GOSSIP_STORE_VERSION)
|
||||
return gs;
|
||||
|
||||
if (upgrade_gs(gs))
|
||||
return gs;
|
||||
|
||||
status_unusual("Gossip store version %u not %u: removing",
|
||||
gs->version, GOSSIP_STORE_VERSION);
|
||||
if (ftruncate(gs->fd, 0) != 0)
|
||||
@@ -81,9 +200,9 @@ struct gossip_store *gossip_store_new(struct routing_state *rstate)
|
||||
return gs;
|
||||
}
|
||||
|
||||
static u8 *gossip_store_wrap_channel_announcement(const tal_t *ctx,
|
||||
struct routing_state *rstate,
|
||||
const u8 *gossip_msg)
|
||||
static u8 *make_store_channel_amount(const tal_t *ctx,
|
||||
struct routing_state *rstate,
|
||||
const u8 *gossip_msg)
|
||||
{
|
||||
secp256k1_ecdsa_signature node_signature_1, node_signature_2;
|
||||
secp256k1_ecdsa_signature bitcoin_signature_1, bitcoin_signature_2;
|
||||
@@ -107,9 +226,7 @@ static u8 *gossip_store_wrap_channel_announcement(const tal_t *ctx,
|
||||
struct chan *chan = get_channel(rstate, &scid);
|
||||
assert(chan && amount_sat_greater(chan->sat, AMOUNT_SAT(0)));
|
||||
|
||||
u8 *msg = towire_gossip_store_channel_announcement(ctx, gossip_msg,
|
||||
chan->sat);
|
||||
return msg;
|
||||
return towire_gossip_store_channel_amount(ctx, chan->sat);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,44 +235,24 @@ static u8 *gossip_store_wrap_channel_announcement(const tal_t *ctx,
|
||||
* @param fd File descriptor to write the wrapped message into
|
||||
* @param rstate Routing state if we need to look up channel capacity
|
||||
* @param gossip_msg The message to write
|
||||
* @param len The length to increase by amount written.
|
||||
* @return true if the message was wrapped and written
|
||||
* @param lenp The length to increase by amount written.
|
||||
* @return true if the message was written
|
||||
*/
|
||||
static bool gossip_store_append(int fd,
|
||||
struct routing_state *rstate,
|
||||
const u8 *gossip_msg,
|
||||
u64 *len)
|
||||
u64 *lenp)
|
||||
{
|
||||
int t = fromwire_peektype(gossip_msg);
|
||||
u32 msglen;
|
||||
beint32_t checksum, belen;
|
||||
const u8 *msg;
|
||||
|
||||
if (t == WIRE_CHANNEL_ANNOUNCEMENT)
|
||||
msg = gossip_store_wrap_channel_announcement(tmpctx, rstate, gossip_msg);
|
||||
else if(t == WIRE_CHANNEL_UPDATE)
|
||||
msg = towire_gossip_store_channel_update(tmpctx, gossip_msg);
|
||||
else if(t == WIRE_NODE_ANNOUNCEMENT)
|
||||
msg = towire_gossip_store_node_announcement(tmpctx, gossip_msg);
|
||||
else if(t == WIRE_GOSSIPD_LOCAL_ADD_CHANNEL)
|
||||
msg = towire_gossip_store_local_add_channel(tmpctx, gossip_msg);
|
||||
else if(t == WIRE_GOSSIP_STORE_CHANNEL_DELETE)
|
||||
msg = gossip_msg;
|
||||
else {
|
||||
status_trace("Unexpected message passed to gossip_store: %s",
|
||||
wire_type_name(t));
|
||||
if (!append_msg(fd, gossip_msg, lenp))
|
||||
return false;
|
||||
|
||||
if (fromwire_peektype(gossip_msg) == WIRE_CHANNEL_ANNOUNCEMENT) {
|
||||
/* This gives the channel amount. */
|
||||
u8 *msg = make_store_channel_amount(tmpctx, rstate, gossip_msg);
|
||||
if (!append_msg(fd, msg, lenp))
|
||||
return false;
|
||||
}
|
||||
|
||||
msglen = tal_count(msg);
|
||||
belen = cpu_to_be32(msglen);
|
||||
checksum = cpu_to_be32(crc32c(0, msg, msglen));
|
||||
|
||||
*len += sizeof(belen) + sizeof(checksum) + msglen;
|
||||
|
||||
return (write(fd, &belen, sizeof(belen)) == sizeof(belen) &&
|
||||
write(fd, &checksum, sizeof(checksum)) == sizeof(checksum) &&
|
||||
write(fd, msg, msglen) == msglen);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Copy a whole message from one gossip_store to another. Returns
|
||||
@@ -248,6 +345,51 @@ static bool add_local_unnannounced(int in_fd, int out_fd,
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Returns bytes transferred, or 0 on error */
|
||||
static size_t transfer_store_msg(int from_fd, size_t from_off, int to_fd,
|
||||
int *type)
|
||||
{
|
||||
beint32_t hdr[2];
|
||||
u32 msglen;
|
||||
u8 *msg;
|
||||
const u8 *p;
|
||||
size_t tmplen;
|
||||
|
||||
if (pread(from_fd, hdr, sizeof(hdr), from_off) != sizeof(hdr)) {
|
||||
status_broken("Failed reading header from to gossip store @%zu"
|
||||
": %s",
|
||||
from_off, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
msglen = be32_to_cpu(hdr[0]);
|
||||
/* FIXME: Reuse buffer? */
|
||||
msg = tal_arr(tmpctx, u8, sizeof(hdr) + msglen);
|
||||
memcpy(msg, hdr, sizeof(hdr));
|
||||
if (pread(from_fd, msg + sizeof(hdr), msglen, from_off + sizeof(hdr))
|
||||
!= msglen) {
|
||||
status_broken("Failed reading %u from to gossip store @%zu"
|
||||
": %s",
|
||||
msglen, from_off, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (write(to_fd, msg, msglen + sizeof(hdr)) != msglen + sizeof(hdr)) {
|
||||
status_broken("Failed writing to gossip store: %s",
|
||||
strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Can't use peektype here, since we have header on front */
|
||||
p = msg + sizeof(hdr);
|
||||
tmplen = msglen;
|
||||
*type = fromwire_u16(&p, &tmplen);
|
||||
if (!p)
|
||||
*type = -1;
|
||||
tal_free(msg);
|
||||
return sizeof(hdr) + msglen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewrite the on-disk gossip store, compacting it along the way
|
||||
*
|
||||
@@ -295,42 +437,34 @@ bool gossip_store_compact(struct gossip_store *gs,
|
||||
|
||||
/* Copy entries one at a time. */
|
||||
while ((bcast = next_broadcast_raw(oldb, &idx)) != NULL) {
|
||||
beint32_t hdr[2];
|
||||
u32 msglen;
|
||||
u8 *msg;
|
||||
u64 old_index = bcast->index;
|
||||
int msgtype;
|
||||
size_t msg_len;
|
||||
|
||||
if (pread(gs->fd, hdr, sizeof(hdr), bcast->index) != sizeof(hdr)) {
|
||||
status_broken("Failed reading header from to gossip store @%u"
|
||||
": %s",
|
||||
bcast->index, strerror(errno));
|
||||
msg_len = transfer_store_msg(gs->fd, bcast->index, fd, &msgtype);
|
||||
if (msg_len == 0)
|
||||
goto unlink_disable;
|
||||
}
|
||||
|
||||
msglen = be32_to_cpu(hdr[0]);
|
||||
/* FIXME: Reuse buffer? */
|
||||
msg = tal_arr(tmpctx, u8, sizeof(hdr) + msglen);
|
||||
memcpy(msg, hdr, sizeof(hdr));
|
||||
if (pread(gs->fd, msg + sizeof(hdr), msglen,
|
||||
bcast->index + sizeof(hdr))
|
||||
!= msglen) {
|
||||
status_broken("Failed reading %u from to gossip store @%u"
|
||||
": %s",
|
||||
msglen, bcast->index, strerror(errno));
|
||||
goto unlink_disable;
|
||||
}
|
||||
|
||||
broadcast_del(oldb, bcast);
|
||||
bcast->index = len;
|
||||
insert_broadcast_nostore(newb, bcast);
|
||||
|
||||
if (write(fd, msg, msglen + sizeof(hdr))
|
||||
!= msglen + sizeof(hdr)) {
|
||||
status_broken("Failed writing to gossip store: %s",
|
||||
strerror(errno));
|
||||
goto unlink_disable;
|
||||
}
|
||||
len += sizeof(hdr) + msglen;
|
||||
len += msg_len;
|
||||
count++;
|
||||
|
||||
/* channel_announcement always followed by amount: copy too */
|
||||
if (msgtype == WIRE_CHANNEL_ANNOUNCEMENT) {
|
||||
msg_len = transfer_store_msg(gs->fd, old_index + msg_len,
|
||||
fd, &msgtype);
|
||||
if (msg_len == 0)
|
||||
goto unlink_disable;
|
||||
if (msgtype != WIRE_GOSSIP_STORE_CHANNEL_AMOUNT) {
|
||||
status_broken("gossip_store: unexpected type %u",
|
||||
msgtype);
|
||||
goto unlink_disable;
|
||||
}
|
||||
len += msg_len;
|
||||
/* This amount field doesn't add to count. */
|
||||
}
|
||||
}
|
||||
|
||||
/* Local unannounced channels are not in the store! */
|
||||
@@ -427,8 +561,7 @@ const u8 *gossip_store_get(const tal_t *ctx,
|
||||
{
|
||||
beint32_t hdr[2];
|
||||
u32 msglen, checksum;
|
||||
u8 *msg, *gossip_msg;
|
||||
struct amount_sat satoshis;
|
||||
u8 *msg;
|
||||
|
||||
if (offset == 0 || offset > gs->len)
|
||||
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
||||
@@ -444,7 +577,7 @@ const u8 *gossip_store_get(const tal_t *ctx,
|
||||
|
||||
msglen = be32_to_cpu(hdr[0]);
|
||||
checksum = be32_to_cpu(hdr[1]);
|
||||
msg = tal_arr(tmpctx, u8, msglen);
|
||||
msg = tal_arr(ctx, u8, msglen);
|
||||
if (pread(gs->fd, msg, msglen, offset + sizeof(hdr)) != msglen)
|
||||
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
||||
"gossip_store: can't read len %u offset %"PRIu64
|
||||
@@ -457,30 +590,21 @@ const u8 *gossip_store_get(const tal_t *ctx,
|
||||
", store len %"PRIu64,
|
||||
offset, gs->len);
|
||||
|
||||
/* Now try decoding it */
|
||||
if (!fromwire_gossip_store_node_announcement(ctx, msg, &gossip_msg)
|
||||
&& !fromwire_gossip_store_channel_announcement(ctx, msg,
|
||||
&gossip_msg,
|
||||
&satoshis)
|
||||
&& !fromwire_gossip_store_channel_update(ctx, msg, &gossip_msg)) {
|
||||
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
||||
"gossip_store: bad message %s offset %"PRIu64
|
||||
" from store len %"PRIu64,
|
||||
tal_hex(tmpctx, msg), offset, gs->len);
|
||||
}
|
||||
return gossip_msg;
|
||||
return msg;
|
||||
}
|
||||
|
||||
void gossip_store_load(struct routing_state *rstate, struct gossip_store *gs)
|
||||
{
|
||||
beint32_t hdr[2];
|
||||
u32 msglen, checksum;
|
||||
u8 *msg, *gossip_msg;
|
||||
u8 *msg;
|
||||
struct amount_sat satoshis;
|
||||
struct short_channel_id scid;
|
||||
const char *bad;
|
||||
size_t stats[] = {0, 0, 0, 0};
|
||||
struct timeabs start = time_now();
|
||||
const u8 *chan_ann = NULL;
|
||||
u64 chan_ann_off;
|
||||
|
||||
gs->writable = false;
|
||||
while (pread(gs->fd, hdr, sizeof(hdr), gs->len) == sizeof(hdr)) {
|
||||
@@ -498,52 +622,81 @@ void gossip_store_load(struct routing_state *rstate, struct gossip_store *gs)
|
||||
goto truncate;
|
||||
}
|
||||
|
||||
if (fromwire_gossip_store_channel_announcement(msg, msg,
|
||||
&gossip_msg,
|
||||
&satoshis)) {
|
||||
switch (fromwire_peektype(msg)) {
|
||||
case WIRE_GOSSIP_STORE_CHANNEL_AMOUNT:
|
||||
if (!fromwire_gossip_store_channel_amount(msg,
|
||||
&satoshis)) {
|
||||
bad = "Bad gossip_store_channel_amount";
|
||||
goto truncate;
|
||||
}
|
||||
/* Should follow channel_announcement */
|
||||
if (!chan_ann) {
|
||||
bad = "gossip_store_channel_amount without"
|
||||
" channel_announcement";
|
||||
goto truncate;
|
||||
}
|
||||
if (!routing_add_channel_announcement(rstate,
|
||||
take(gossip_msg),
|
||||
take(chan_ann),
|
||||
satoshis,
|
||||
gs->len)) {
|
||||
chan_ann_off)) {
|
||||
bad = "Bad channel_announcement";
|
||||
goto truncate;
|
||||
}
|
||||
chan_ann = NULL;
|
||||
stats[0]++;
|
||||
} else if (fromwire_gossip_store_channel_update(msg, msg,
|
||||
&gossip_msg)) {
|
||||
break;
|
||||
case WIRE_CHANNEL_ANNOUNCEMENT:
|
||||
if (chan_ann) {
|
||||
bad = "channel_announcement without amount";
|
||||
goto truncate;
|
||||
}
|
||||
/* Save for channel_amount (next msg) */
|
||||
chan_ann = tal_steal(gs, msg);
|
||||
chan_ann_off = gs->len;
|
||||
break;
|
||||
case WIRE_CHANNEL_UPDATE:
|
||||
if (!routing_add_channel_update(rstate,
|
||||
take(gossip_msg),
|
||||
gs->len)) {
|
||||
take(msg), gs->len)) {
|
||||
bad = "Bad channel_update";
|
||||
goto truncate;
|
||||
}
|
||||
stats[1]++;
|
||||
} else if (fromwire_gossip_store_node_announcement(msg, msg,
|
||||
&gossip_msg)) {
|
||||
break;
|
||||
case WIRE_NODE_ANNOUNCEMENT:
|
||||
if (!routing_add_node_announcement(rstate,
|
||||
take(gossip_msg),
|
||||
gs->len)) {
|
||||
take(msg), gs->len)) {
|
||||
bad = "Bad node_announcement";
|
||||
goto truncate;
|
||||
}
|
||||
stats[2]++;
|
||||
} else if (fromwire_gossip_store_channel_delete(msg, &scid)) {
|
||||
break;
|
||||
case WIRE_GOSSIP_STORE_CHANNEL_DELETE:
|
||||
if (!fromwire_gossip_store_channel_delete(msg, &scid)) {
|
||||
bad = "Bad channel_delete";
|
||||
goto truncate;
|
||||
}
|
||||
struct chan *c = get_channel(rstate, &scid);
|
||||
if (!c) {
|
||||
bad = "Bad channel_delete";
|
||||
bad = "Bad channel_delete scid";
|
||||
goto truncate;
|
||||
}
|
||||
tal_free(c);
|
||||
stats[3]++;
|
||||
} else if (fromwire_gossip_store_local_add_channel(
|
||||
msg, msg, &gossip_msg)) {
|
||||
handle_local_add_channel(rstate, gossip_msg);
|
||||
} else {
|
||||
break;
|
||||
case WIRE_GOSSIPD_LOCAL_ADD_CHANNEL:
|
||||
if (!handle_local_add_channel(rstate, msg)) {
|
||||
bad = "Bad local_add_channel";
|
||||
goto truncate;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
bad = "Unknown message";
|
||||
goto truncate;
|
||||
}
|
||||
gs->len += sizeof(hdr) + msglen;
|
||||
gs->count++;
|
||||
|
||||
if (fromwire_peektype(msg) != WIRE_GOSSIP_STORE_CHANNEL_AMOUNT)
|
||||
gs->count++;
|
||||
clean_tmpctx();
|
||||
}
|
||||
goto out;
|
||||
|
||||
@@ -1,20 +1,28 @@
|
||||
# gossip_store messages: messages persisted in the gossip_store
|
||||
gossip_store_channel_announcement,4096
|
||||
gossip_store_channel_announcement,,len,u16
|
||||
gossip_store_channel_announcement,,announcement,len*u8
|
||||
gossip_store_channel_announcement,,satoshis,struct amount_sat
|
||||
# We store raw messages here, so these numbers must not overlap with
|
||||
# 256/257/258 or gossipd_local_add_channel (3503)
|
||||
|
||||
gossip_store_channel_update,4097
|
||||
gossip_store_channel_update,,len,u16
|
||||
gossip_store_channel_update,,update,len*u8
|
||||
|
||||
gossip_store_node_announcement,4098
|
||||
gossip_store_node_announcement,,len,u16
|
||||
gossip_store_node_announcement,,announcement,len*u8
|
||||
# This always follows the channel_announce.
|
||||
gossip_store_channel_amount,4101
|
||||
gossip_store_channel_amount,,satoshis,struct amount_sat
|
||||
|
||||
gossip_store_channel_delete,4099
|
||||
gossip_store_channel_delete,,short_channel_id,struct short_channel_id
|
||||
|
||||
gossip_store_local_add_channel,4100
|
||||
gossip_store_local_add_channel,,len,u16
|
||||
gossip_store_local_add_channel,,local_add,len*u8
|
||||
### Older v3 messages
|
||||
gossip_store_v3_channel_announcement,4096
|
||||
gossip_store_v3_channel_announcement,,len,u16
|
||||
gossip_store_v3_channel_announcement,,announcement,len*u8
|
||||
gossip_store_v3_channel_announcement,,satoshis,struct amount_sat
|
||||
|
||||
gossip_store_v3_channel_update,4097
|
||||
gossip_store_v3_channel_update,,len,u16
|
||||
gossip_store_v3_channel_update,,update,len*u8
|
||||
|
||||
gossip_store_v3_node_announcement,4098
|
||||
gossip_store_v3_node_announcement,,len,u16
|
||||
gossip_store_v3_node_announcement,,announcement,len*u8
|
||||
|
||||
gossip_store_v3_local_add_channel,4100
|
||||
gossip_store_v3_local_add_channel,,len,u16
|
||||
gossip_store_v3_local_add_channel,,local_add,len*u8
|
||||
|
||||
|
@@ -11,7 +11,7 @@
|
||||
/**
|
||||
* gossip_store -- On-disk storage related information
|
||||
*/
|
||||
#define GOSSIP_STORE_VERSION 3
|
||||
#define GOSSIP_STORE_VERSION 4
|
||||
|
||||
struct broadcast_state;
|
||||
struct gossip_store;
|
||||
|
||||
@@ -39,27 +39,33 @@ bool fromwire_channel_update_option_channel_htlc_max(const void *p UNNEEDED, sec
|
||||
/* Generated stub for fromwire_gossipd_local_add_channel */
|
||||
bool fromwire_gossipd_local_add_channel(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct node_id *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossipd_local_add_channel called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_channel_announcement */
|
||||
bool fromwire_gossip_store_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED, struct amount_sat *satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_channel_announcement called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_channel_amount */
|
||||
bool fromwire_gossip_store_channel_amount(const void *p UNNEEDED, struct amount_sat *satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_channel_amount called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_channel_delete */
|
||||
bool fromwire_gossip_store_channel_delete(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_channel_delete called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_channel_update */
|
||||
bool fromwire_gossip_store_channel_update(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **update UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_channel_update called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_local_add_channel */
|
||||
bool fromwire_gossip_store_local_add_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **local_add UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_local_add_channel called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_node_announcement */
|
||||
bool fromwire_gossip_store_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_node_announcement called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_v3_channel_announcement */
|
||||
bool fromwire_gossip_store_v3_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED, struct amount_sat *satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_v3_channel_announcement called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_v3_channel_update */
|
||||
bool fromwire_gossip_store_v3_channel_update(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **update UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_v3_channel_update called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_v3_local_add_channel */
|
||||
bool fromwire_gossip_store_v3_local_add_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **local_add UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_v3_local_add_channel called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_v3_node_announcement */
|
||||
bool fromwire_gossip_store_v3_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_v3_node_announcement called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_node_announcement */
|
||||
bool fromwire_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, u8 **features UNNEEDED, u32 *timestamp UNNEEDED, struct node_id *node_id UNNEEDED, u8 rgb_color[3] UNNEEDED, u8 alias[32] UNNEEDED, u8 **addresses UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_node_announcement called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_peektype */
|
||||
int fromwire_peektype(const u8 *cursor UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_peektype called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_u16 */
|
||||
u16 fromwire_u16(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_u16 called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_wireaddr */
|
||||
bool fromwire_wireaddr(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct wireaddr *addr UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_wireaddr called!\n"); abort(); }
|
||||
@@ -82,21 +88,12 @@ u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
|
||||
/* Generated stub for towire_gossipd_local_add_channel */
|
||||
u8 *towire_gossipd_local_add_channel(const tal_t *ctx UNNEEDED, const struct short_channel_id *short_channel_id UNNEEDED, const struct node_id *remote_node_id UNNEEDED, struct amount_sat satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossipd_local_add_channel called!\n"); abort(); }
|
||||
/* Generated stub for towire_gossip_store_channel_announcement */
|
||||
u8 *towire_gossip_store_channel_announcement(const tal_t *ctx UNNEEDED, const u8 *announcement UNNEEDED, struct amount_sat satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossip_store_channel_announcement called!\n"); abort(); }
|
||||
/* Generated stub for towire_gossip_store_channel_amount */
|
||||
u8 *towire_gossip_store_channel_amount(const tal_t *ctx UNNEEDED, struct amount_sat satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossip_store_channel_amount called!\n"); abort(); }
|
||||
/* Generated stub for towire_gossip_store_channel_delete */
|
||||
u8 *towire_gossip_store_channel_delete(const tal_t *ctx UNNEEDED, const struct short_channel_id *short_channel_id UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossip_store_channel_delete called!\n"); abort(); }
|
||||
/* Generated stub for towire_gossip_store_channel_update */
|
||||
u8 *towire_gossip_store_channel_update(const tal_t *ctx UNNEEDED, const u8 *update UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossip_store_channel_update called!\n"); abort(); }
|
||||
/* Generated stub for towire_gossip_store_local_add_channel */
|
||||
u8 *towire_gossip_store_local_add_channel(const tal_t *ctx UNNEEDED, const u8 *local_add UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossip_store_local_add_channel called!\n"); abort(); }
|
||||
/* Generated stub for towire_gossip_store_node_announcement */
|
||||
u8 *towire_gossip_store_node_announcement(const tal_t *ctx UNNEEDED, const u8 *announcement UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossip_store_node_announcement called!\n"); abort(); }
|
||||
/* Generated stub for update_peers_broadcast_index */
|
||||
void update_peers_broadcast_index(struct list_head *peers UNNEEDED, u32 offset UNNEEDED)
|
||||
{ fprintf(stderr, "update_peers_broadcast_index called!\n"); abort(); }
|
||||
|
||||
@@ -28,27 +28,33 @@ bool fromwire_channel_update_option_channel_htlc_max(const void *p UNNEEDED, sec
|
||||
/* Generated stub for fromwire_gossipd_local_add_channel */
|
||||
bool fromwire_gossipd_local_add_channel(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct node_id *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossipd_local_add_channel called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_channel_announcement */
|
||||
bool fromwire_gossip_store_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED, struct amount_sat *satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_channel_announcement called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_channel_amount */
|
||||
bool fromwire_gossip_store_channel_amount(const void *p UNNEEDED, struct amount_sat *satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_channel_amount called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_channel_delete */
|
||||
bool fromwire_gossip_store_channel_delete(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_channel_delete called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_channel_update */
|
||||
bool fromwire_gossip_store_channel_update(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **update UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_channel_update called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_local_add_channel */
|
||||
bool fromwire_gossip_store_local_add_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **local_add UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_local_add_channel called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_node_announcement */
|
||||
bool fromwire_gossip_store_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_node_announcement called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_v3_channel_announcement */
|
||||
bool fromwire_gossip_store_v3_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED, struct amount_sat *satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_v3_channel_announcement called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_v3_channel_update */
|
||||
bool fromwire_gossip_store_v3_channel_update(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **update UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_v3_channel_update called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_v3_local_add_channel */
|
||||
bool fromwire_gossip_store_v3_local_add_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **local_add UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_v3_local_add_channel called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_v3_node_announcement */
|
||||
bool fromwire_gossip_store_v3_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_v3_node_announcement called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_node_announcement */
|
||||
bool fromwire_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, u8 **features UNNEEDED, u32 *timestamp UNNEEDED, struct node_id *node_id UNNEEDED, u8 rgb_color[3] UNNEEDED, u8 alias[32] UNNEEDED, u8 **addresses UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_node_announcement called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_peektype */
|
||||
int fromwire_peektype(const u8 *cursor UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_peektype called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_u16 */
|
||||
u16 fromwire_u16(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_u16 called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_wireaddr */
|
||||
bool fromwire_wireaddr(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct wireaddr *addr UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_wireaddr called!\n"); abort(); }
|
||||
@@ -71,21 +77,12 @@ u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
|
||||
/* Generated stub for towire_gossipd_local_add_channel */
|
||||
u8 *towire_gossipd_local_add_channel(const tal_t *ctx UNNEEDED, const struct short_channel_id *short_channel_id UNNEEDED, const struct node_id *remote_node_id UNNEEDED, struct amount_sat satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossipd_local_add_channel called!\n"); abort(); }
|
||||
/* Generated stub for towire_gossip_store_channel_announcement */
|
||||
u8 *towire_gossip_store_channel_announcement(const tal_t *ctx UNNEEDED, const u8 *announcement UNNEEDED, struct amount_sat satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossip_store_channel_announcement called!\n"); abort(); }
|
||||
/* Generated stub for towire_gossip_store_channel_amount */
|
||||
u8 *towire_gossip_store_channel_amount(const tal_t *ctx UNNEEDED, struct amount_sat satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossip_store_channel_amount called!\n"); abort(); }
|
||||
/* Generated stub for towire_gossip_store_channel_delete */
|
||||
u8 *towire_gossip_store_channel_delete(const tal_t *ctx UNNEEDED, const struct short_channel_id *short_channel_id UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossip_store_channel_delete called!\n"); abort(); }
|
||||
/* Generated stub for towire_gossip_store_channel_update */
|
||||
u8 *towire_gossip_store_channel_update(const tal_t *ctx UNNEEDED, const u8 *update UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossip_store_channel_update called!\n"); abort(); }
|
||||
/* Generated stub for towire_gossip_store_local_add_channel */
|
||||
u8 *towire_gossip_store_local_add_channel(const tal_t *ctx UNNEEDED, const u8 *local_add UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossip_store_local_add_channel called!\n"); abort(); }
|
||||
/* Generated stub for towire_gossip_store_node_announcement */
|
||||
u8 *towire_gossip_store_node_announcement(const tal_t *ctx UNNEEDED, const u8 *announcement UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossip_store_node_announcement called!\n"); abort(); }
|
||||
/* Generated stub for update_peers_broadcast_index */
|
||||
void update_peers_broadcast_index(struct list_head *peers UNNEEDED, u32 offset UNNEEDED)
|
||||
{ fprintf(stderr, "update_peers_broadcast_index called!\n"); abort(); }
|
||||
|
||||
@@ -26,27 +26,33 @@ bool fromwire_channel_update_option_channel_htlc_max(const void *p UNNEEDED, sec
|
||||
/* Generated stub for fromwire_gossipd_local_add_channel */
|
||||
bool fromwire_gossipd_local_add_channel(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct node_id *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossipd_local_add_channel called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_channel_announcement */
|
||||
bool fromwire_gossip_store_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED, struct amount_sat *satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_channel_announcement called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_channel_amount */
|
||||
bool fromwire_gossip_store_channel_amount(const void *p UNNEEDED, struct amount_sat *satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_channel_amount called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_channel_delete */
|
||||
bool fromwire_gossip_store_channel_delete(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_channel_delete called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_channel_update */
|
||||
bool fromwire_gossip_store_channel_update(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **update UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_channel_update called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_local_add_channel */
|
||||
bool fromwire_gossip_store_local_add_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **local_add UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_local_add_channel called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_node_announcement */
|
||||
bool fromwire_gossip_store_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_node_announcement called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_v3_channel_announcement */
|
||||
bool fromwire_gossip_store_v3_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED, struct amount_sat *satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_v3_channel_announcement called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_v3_channel_update */
|
||||
bool fromwire_gossip_store_v3_channel_update(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **update UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_v3_channel_update called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_v3_local_add_channel */
|
||||
bool fromwire_gossip_store_v3_local_add_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **local_add UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_v3_local_add_channel called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_v3_node_announcement */
|
||||
bool fromwire_gossip_store_v3_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_v3_node_announcement called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_node_announcement */
|
||||
bool fromwire_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, u8 **features UNNEEDED, u32 *timestamp UNNEEDED, struct node_id *node_id UNNEEDED, u8 rgb_color[3] UNNEEDED, u8 alias[32] UNNEEDED, u8 **addresses UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_node_announcement called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_peektype */
|
||||
int fromwire_peektype(const u8 *cursor UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_peektype called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_u16 */
|
||||
u16 fromwire_u16(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_u16 called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_wireaddr */
|
||||
bool fromwire_wireaddr(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct wireaddr *addr UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_wireaddr called!\n"); abort(); }
|
||||
@@ -69,21 +75,12 @@ u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
|
||||
/* Generated stub for towire_gossipd_local_add_channel */
|
||||
u8 *towire_gossipd_local_add_channel(const tal_t *ctx UNNEEDED, const struct short_channel_id *short_channel_id UNNEEDED, const struct node_id *remote_node_id UNNEEDED, struct amount_sat satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossipd_local_add_channel called!\n"); abort(); }
|
||||
/* Generated stub for towire_gossip_store_channel_announcement */
|
||||
u8 *towire_gossip_store_channel_announcement(const tal_t *ctx UNNEEDED, const u8 *announcement UNNEEDED, struct amount_sat satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossip_store_channel_announcement called!\n"); abort(); }
|
||||
/* Generated stub for towire_gossip_store_channel_amount */
|
||||
u8 *towire_gossip_store_channel_amount(const tal_t *ctx UNNEEDED, struct amount_sat satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossip_store_channel_amount called!\n"); abort(); }
|
||||
/* Generated stub for towire_gossip_store_channel_delete */
|
||||
u8 *towire_gossip_store_channel_delete(const tal_t *ctx UNNEEDED, const struct short_channel_id *short_channel_id UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossip_store_channel_delete called!\n"); abort(); }
|
||||
/* Generated stub for towire_gossip_store_channel_update */
|
||||
u8 *towire_gossip_store_channel_update(const tal_t *ctx UNNEEDED, const u8 *update UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossip_store_channel_update called!\n"); abort(); }
|
||||
/* Generated stub for towire_gossip_store_local_add_channel */
|
||||
u8 *towire_gossip_store_local_add_channel(const tal_t *ctx UNNEEDED, const u8 *local_add UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossip_store_local_add_channel called!\n"); abort(); }
|
||||
/* Generated stub for towire_gossip_store_node_announcement */
|
||||
u8 *towire_gossip_store_node_announcement(const tal_t *ctx UNNEEDED, const u8 *announcement UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossip_store_node_announcement called!\n"); abort(); }
|
||||
/* Generated stub for update_peers_broadcast_index */
|
||||
void update_peers_broadcast_index(struct list_head *peers UNNEEDED, u32 offset UNNEEDED)
|
||||
{ fprintf(stderr, "update_peers_broadcast_index called!\n"); abort(); }
|
||||
|
||||
@@ -26,27 +26,33 @@ bool fromwire_channel_update_option_channel_htlc_max(const void *p UNNEEDED, sec
|
||||
/* Generated stub for fromwire_gossipd_local_add_channel */
|
||||
bool fromwire_gossipd_local_add_channel(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct node_id *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossipd_local_add_channel called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_channel_announcement */
|
||||
bool fromwire_gossip_store_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED, struct amount_sat *satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_channel_announcement called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_channel_amount */
|
||||
bool fromwire_gossip_store_channel_amount(const void *p UNNEEDED, struct amount_sat *satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_channel_amount called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_channel_delete */
|
||||
bool fromwire_gossip_store_channel_delete(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_channel_delete called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_channel_update */
|
||||
bool fromwire_gossip_store_channel_update(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **update UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_channel_update called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_local_add_channel */
|
||||
bool fromwire_gossip_store_local_add_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **local_add UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_local_add_channel called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_node_announcement */
|
||||
bool fromwire_gossip_store_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_node_announcement called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_v3_channel_announcement */
|
||||
bool fromwire_gossip_store_v3_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED, struct amount_sat *satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_v3_channel_announcement called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_v3_channel_update */
|
||||
bool fromwire_gossip_store_v3_channel_update(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **update UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_v3_channel_update called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_v3_local_add_channel */
|
||||
bool fromwire_gossip_store_v3_local_add_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **local_add UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_v3_local_add_channel called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_store_v3_node_announcement */
|
||||
bool fromwire_gossip_store_v3_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_v3_node_announcement called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_node_announcement */
|
||||
bool fromwire_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, u8 **features UNNEEDED, u32 *timestamp UNNEEDED, struct node_id *node_id UNNEEDED, u8 rgb_color[3] UNNEEDED, u8 alias[32] UNNEEDED, u8 **addresses UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_node_announcement called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_peektype */
|
||||
int fromwire_peektype(const u8 *cursor UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_peektype called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_u16 */
|
||||
u16 fromwire_u16(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_u16 called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_wireaddr */
|
||||
bool fromwire_wireaddr(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct wireaddr *addr UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_wireaddr called!\n"); abort(); }
|
||||
@@ -69,21 +75,12 @@ u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
|
||||
/* Generated stub for towire_gossipd_local_add_channel */
|
||||
u8 *towire_gossipd_local_add_channel(const tal_t *ctx UNNEEDED, const struct short_channel_id *short_channel_id UNNEEDED, const struct node_id *remote_node_id UNNEEDED, struct amount_sat satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossipd_local_add_channel called!\n"); abort(); }
|
||||
/* Generated stub for towire_gossip_store_channel_announcement */
|
||||
u8 *towire_gossip_store_channel_announcement(const tal_t *ctx UNNEEDED, const u8 *announcement UNNEEDED, struct amount_sat satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossip_store_channel_announcement called!\n"); abort(); }
|
||||
/* Generated stub for towire_gossip_store_channel_amount */
|
||||
u8 *towire_gossip_store_channel_amount(const tal_t *ctx UNNEEDED, struct amount_sat satoshis UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossip_store_channel_amount called!\n"); abort(); }
|
||||
/* Generated stub for towire_gossip_store_channel_delete */
|
||||
u8 *towire_gossip_store_channel_delete(const tal_t *ctx UNNEEDED, const struct short_channel_id *short_channel_id UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossip_store_channel_delete called!\n"); abort(); }
|
||||
/* Generated stub for towire_gossip_store_channel_update */
|
||||
u8 *towire_gossip_store_channel_update(const tal_t *ctx UNNEEDED, const u8 *update UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossip_store_channel_update called!\n"); abort(); }
|
||||
/* Generated stub for towire_gossip_store_local_add_channel */
|
||||
u8 *towire_gossip_store_local_add_channel(const tal_t *ctx UNNEEDED, const u8 *local_add UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossip_store_local_add_channel called!\n"); abort(); }
|
||||
/* Generated stub for towire_gossip_store_node_announcement */
|
||||
u8 *towire_gossip_store_node_announcement(const tal_t *ctx UNNEEDED, const u8 *announcement UNNEEDED)
|
||||
{ fprintf(stderr, "towire_gossip_store_node_announcement called!\n"); abort(); }
|
||||
/* Generated stub for update_peers_broadcast_index */
|
||||
void update_peers_broadcast_index(struct list_head *peers UNNEEDED, u32 offset UNNEEDED)
|
||||
{ fprintf(stderr, "update_peers_broadcast_index called!\n"); abort(); }
|
||||
|
||||
@@ -877,8 +877,9 @@ def test_gossip_store_load(node_factory):
|
||||
|
||||
l1.start()
|
||||
# May preceed the Started msg waited for in 'start'.
|
||||
wait_for(lambda: l1.daemon.is_in_log('gossip_store: Read 1/1/1/0 cannounce/cupdate/nannounce/cdelete from store in 756 bytes'))
|
||||
wait_for(lambda: l1.daemon.is_in_log('gossip_store: Read 1/1/1/0 cannounce/cupdate/nannounce/cdelete from store in 754 bytes'))
|
||||
assert not l1.daemon.is_in_log('gossip_store.*truncating')
|
||||
assert l1.daemon.is_in_log('Upgraded gossip_store from version 3 to 4')
|
||||
|
||||
|
||||
@unittest.skipIf(not DEVELOPER, "Needs fast gossip propagation")
|
||||
|
||||
@@ -17,7 +17,8 @@ wait_for_start()
|
||||
ID="$($LCLI1 -H getinfo 2>/dev/null | grep '^id=' | cut -d= -f2)"
|
||||
sleep 1
|
||||
i=$((i + 1))
|
||||
if [ $i = 10 ]; then
|
||||
# If it has to upgrade the gossip store, that can take a while!
|
||||
if [ $i = 120 ]; then
|
||||
echo "lightningd didn't start?" >&2
|
||||
cat "$DIR"/log
|
||||
exit 1
|
||||
@@ -98,7 +99,8 @@ fi
|
||||
if $CSV; then echo $TARGETS | tr ' ' ,; fi
|
||||
|
||||
# First, measure load time.
|
||||
rm -f "$DIR"/log "$DIR"/peer
|
||||
rm -f "$DIR"/peer
|
||||
mv "$DIR"/log "$DIR"/log.old.$$
|
||||
$LIGHTNINGD --lightning-dir="$DIR" --log-file="$DIR"/log --bind-addr="$DIR"/peer &
|
||||
|
||||
rm -f "$DIR"/stats
|
||||
@@ -149,6 +151,7 @@ fi
|
||||
# Try getting all from the peer.
|
||||
if [ -z "${TARGETS##* peer_write_all_sec *}" ]; then
|
||||
ENTRIES=$(grep 'Read .* cannounce/cupdate/nannounce/cdelete' "$DIR"/log | cut -d\ -f5 | tr / + | bc)
|
||||
if [ "$ENTRIES" = 0 ]; then echo "Bad store?"; exit 1; fi
|
||||
/usr/bin/time --quiet --append -f %e devtools/gossipwith --initial-sync --max-messages=$((ENTRIES - 5)) "$ID"@"$DIR"/peer 2>&1 > /dev/null | print_stat peer_write_all_sec
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user