From b0c2e3cd5c6dd77950284a498dcf5aed5d83a3f9 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 11 Apr 2018 08:33:36 +0930 Subject: [PATCH] gossipd: use a separate CSV file for the gossip_store types. Signed-off-by: Rusty Russell --- gossipd/Makefile | 8 ++++++++ gossipd/gossip.c | 5 ----- gossipd/gossip_store.c | 2 +- gossipd/gossip_store.csv | 16 ++++++++++++++++ gossipd/gossip_wire.csv | 17 ----------------- gossipd/test/run-bench-find_route.c | 6 ------ gossipd/test/run-find_route-specific.c | 6 ------ gossipd/test/run-find_route.c | 6 ------ lightningd/gossip_control.c | 6 ------ 9 files changed, 25 insertions(+), 47 deletions(-) create mode 100644 gossipd/gossip_store.csv diff --git a/gossipd/Makefile b/gossipd/Makefile index a0a8a92a0..80803dc8e 100644 --- a/gossipd/Makefile +++ b/gossipd/Makefile @@ -13,6 +13,7 @@ LIGHTNINGD_GOSSIP_CONTROL_OBJS := $(LIGHTNINGD_GOSSIP_CONTROL_SRC:.c=.o) # gossipd needs these: LIGHTNINGD_GOSSIP_HEADERS := gossipd/gen_gossip_wire.h \ + gossipd/gen_gossip_store.h \ gossipd/gossip_store.h \ gossipd/handshake.h \ gossipd/routing.h \ @@ -76,6 +77,13 @@ gossipd/gen_gossip_wire.h: $(WIRE_GEN) gossipd/gossip_wire.csv gossipd/gen_gossip_wire.c: $(WIRE_GEN) gossipd/gossip_wire.csv $(WIRE_GEN) ${@:.c=.h} gossip_wire_type < gossipd/gossip_wire.csv > $@ +gossipd/gen_gossip_store.h: $(WIRE_GEN) gossipd/gossip_store.csv + $(WIRE_GEN) --header $@ gossip_store_type < gossipd/gossip_store.csv > $@ + +gossipd/gen_gossip_store.c: $(WIRE_GEN) gossipd/gossip_store.csv + $(WIRE_GEN) ${@:.c=.h} gossip_store_type < gossipd/gossip_store.csv > $@ + + check-source: $(LIGHTNINGD_GOSSIP_ALLSRC_NOGEN:%=check-src-include-order/%) $(LIGHTNINGD_GOSSIP_ALLHEADERS_NOGEN:%=check-hdr-include-order/%) check-source-bolt: $(LIGHTNINGD_GOSSIP_SRC:%=bolt-check/%) $(LIGHTNINGD_GOSSIP_HEADERS:%=bolt-check/%) check-whitespace: $(LIGHTNINGD_GOSSIP_ALLSRC_NOGEN:%=check-whitespace/%) $(LIGHTNINGD_GOSSIP_ALLHEADERS_NOGEN:%=check-whitespace/%) diff --git a/gossipd/gossip.c b/gossipd/gossip.c index e91478f9a..5e26fecd7 100644 --- a/gossipd/gossip.c +++ b/gossipd/gossip.c @@ -2092,11 +2092,6 @@ static struct io_plan *recv_req(struct io_conn *conn, struct daemon_conn *master case WIRE_GOSSIP_GET_TXOUT: case WIRE_GOSSIPCTL_PEER_DISCONNECT_REPLY: case WIRE_GOSSIPCTL_PEER_DISCONNECT_REPLYFAIL: - /* gossip_store messages */ - case WIRE_GOSSIP_STORE_CHANNEL_ANNOUNCEMENT: - case WIRE_GOSSIP_STORE_CHANNEL_UPDATE: - case WIRE_GOSSIP_STORE_NODE_ANNOUNCEMENT: - case WIRE_GOSSIP_STORE_CHANNEL_DELETE: break; } diff --git a/gossipd/gossip_store.c b/gossipd/gossip_store.c index f96002d67..2622d362f 100644 --- a/gossipd/gossip_store.c +++ b/gossipd/gossip_store.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/gossipd/gossip_store.csv b/gossipd/gossip_store.csv new file mode 100644 index 000000000..eaf34fa7a --- /dev/null +++ b/gossipd/gossip_store.csv @@ -0,0 +1,16 @@ +# 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,u64 + +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 + +gossip_store_channel_delete,4099 +gossip_store_channel_delete,,short_channel_id,struct short_channel_id diff --git a/gossipd/gossip_wire.csv b/gossipd/gossip_wire.csv index c8207db77..503e444c9 100644 --- a/gossipd/gossip_wire.csv +++ b/gossipd/gossip_wire.csv @@ -228,20 +228,3 @@ gossipctl_peer_disconnect_replyfail,,isconnected,bool # master -> gossipd: a potential funding outpoint was spent, please forget the eventual channel gossip_outpoint_spent,3024 gossip_outpoint_spent,,short_channel_id,struct short_channel_id - -# 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,u64 - -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 - -gossip_store_channel_delete,4099 -gossip_store_channel_delete,,short_channel_id,struct short_channel_id diff --git a/gossipd/test/run-bench-find_route.c b/gossipd/test/run-bench-find_route.c index 63e2d4680..b0635f634 100644 --- a/gossipd/test/run-bench-find_route.c +++ b/gossipd/test/run-bench-find_route.c @@ -77,18 +77,12 @@ bool fromwire_gossip_store_node_announcement(const tal_t *ctx UNNEEDED, const vo /* 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 pubkey *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_u8 */ u8 fromwire_u8(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) { fprintf(stderr, "fromwire_u8 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(); } -/* Generated stub for gossip_wire_type_name */ -const char *gossip_wire_type_name(int e UNNEEDED) -{ fprintf(stderr, "gossip_wire_type_name called!\n"); abort(); } /* Generated stub for onion_type_name */ const char *onion_type_name(int e UNNEEDED) { fprintf(stderr, "onion_type_name called!\n"); abort(); } diff --git a/gossipd/test/run-find_route-specific.c b/gossipd/test/run-find_route-specific.c index e75b8b256..a262be5c2 100644 --- a/gossipd/test/run-find_route-specific.c +++ b/gossipd/test/run-find_route-specific.c @@ -41,18 +41,12 @@ bool fromwire_gossip_store_node_announcement(const tal_t *ctx UNNEEDED, const vo /* 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 pubkey *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_u8 */ u8 fromwire_u8(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) { fprintf(stderr, "fromwire_u8 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(); } -/* Generated stub for gossip_wire_type_name */ -const char *gossip_wire_type_name(int e UNNEEDED) -{ fprintf(stderr, "gossip_wire_type_name called!\n"); abort(); } /* Generated stub for onion_type_name */ const char *onion_type_name(int e UNNEEDED) { fprintf(stderr, "onion_type_name called!\n"); abort(); } diff --git a/gossipd/test/run-find_route.c b/gossipd/test/run-find_route.c index 3feb5ca4c..e47901748 100644 --- a/gossipd/test/run-find_route.c +++ b/gossipd/test/run-find_route.c @@ -39,18 +39,12 @@ bool fromwire_gossip_store_node_announcement(const tal_t *ctx UNNEEDED, const vo /* 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 pubkey *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_u8 */ u8 fromwire_u8(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) { fprintf(stderr, "fromwire_u8 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(); } -/* Generated stub for gossip_wire_type_name */ -const char *gossip_wire_type_name(int e UNNEEDED) -{ fprintf(stderr, "gossip_wire_type_name called!\n"); abort(); } /* Generated stub for onion_type_name */ const char *onion_type_name(int e UNNEEDED) { fprintf(stderr, "onion_type_name called!\n"); abort(); } diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c index c2bbefafc..809346b44 100644 --- a/lightningd/gossip_control.c +++ b/lightningd/gossip_control.c @@ -149,12 +149,6 @@ static unsigned gossip_msg(struct subd *gossip, const u8 *msg, const int *fds) case WIRE_GOSSIPCTL_RELEASE_PEER_REPLYFAIL: case WIRE_GOSSIPCTL_PEER_DISCONNECT_REPLY: case WIRE_GOSSIPCTL_PEER_DISCONNECT_REPLYFAIL: - /* gossip_store messages */ - case WIRE_GOSSIP_STORE_CHANNEL_ANNOUNCEMENT: - case WIRE_GOSSIP_STORE_CHANNEL_UPDATE: - case WIRE_GOSSIP_STORE_NODE_ANNOUNCEMENT: - case WIRE_GOSSIP_STORE_CHANNEL_DELETE: - break; /* These are inter-daemon messages, not received by us */ case WIRE_GOSSIP_LOCAL_ADD_CHANNEL: break;