From 6a8d18c7e3c98e75a3b56ee993e4e3d6063f4a2a Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 18 Sep 2019 10:35:14 +0930 Subject: [PATCH] gossipd: naming cleanups. Suggested-by: @cdecker. Signed-off-by: Rusty Russell --- gossipd/Makefile | 2 +- gossipd/{make_gossip.c => gossip_generation.c} | 5 +++-- gossipd/{make_gossip.h => gossip_generation.h} | 6 +++--- gossipd/gossipd.c | 6 +++--- gossipd/routing.c | 11 +++++------ gossipd/test/run-crc32_of_update.c | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) rename gossipd/{make_gossip.c => gossip_generation.c} (99%) rename gossipd/{make_gossip.h => gossip_generation.h} (90%) diff --git a/gossipd/Makefile b/gossipd/Makefile index bdc50f6d1..e2354d166 100644 --- a/gossipd/Makefile +++ b/gossipd/Makefile @@ -17,7 +17,7 @@ LIGHTNINGD_GOSSIP_HEADERS_WSRC := gossipd/gen_gossip_wire.h \ gossipd/gen_gossip_store.h \ gossipd/gossipd.h \ gossipd/gossip_store.h \ - gossipd/make_gossip.h \ + gossipd/gossip_generation.h \ gossipd/routing.h LIGHTNINGD_GOSSIP_HEADERS := $(LIGHTNINGD_GOSSIP_HEADERS_WSRC) gossipd/broadcast.h LIGHTNINGD_GOSSIP_SRC := $(LIGHTNINGD_GOSSIP_HEADERS_WSRC:.h=.c) diff --git a/gossipd/make_gossip.c b/gossipd/gossip_generation.c similarity index 99% rename from gossipd/make_gossip.c rename to gossipd/gossip_generation.c index 8008ee403..5d794ee9d 100644 --- a/gossipd/make_gossip.c +++ b/gossipd/gossip_generation.c @@ -1,4 +1,5 @@ -/* Routines to make our own gossip messages */ +/* Routines to make our own gossip messages. Not as in "we're the gossip + * generation, man!" */ #include #include #include @@ -6,9 +7,9 @@ #include #include #include +#include #include #include -#include #include #include #include diff --git a/gossipd/make_gossip.h b/gossipd/gossip_generation.h similarity index 90% rename from gossipd/make_gossip.h rename to gossipd/gossip_generation.h index 88faca7d0..5c4857661 100644 --- a/gossipd/make_gossip.h +++ b/gossipd/gossip_generation.h @@ -1,5 +1,5 @@ -#ifndef LIGHTNING_GOSSIPD_MAKE_GOSSIP_H -#define LIGHTNING_GOSSIPD_MAKE_GOSSIP_H +#ifndef LIGHTNING_GOSSIPD_GOSSIP_GENERATION_H +#define LIGHTNING_GOSSIPD_GOSSIP_GENERATION_H #include "config.h" #include #include @@ -44,4 +44,4 @@ bool handle_local_channel_update(struct daemon *daemon, const struct node_id *src, const u8 *msg); -#endif /* LIGHTNING_GOSSIPD_MAKE_GOSSIP_H */ +#endif /* LIGHTNING_GOSSIPD_GOSSIP_GENERATION_H */ diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c index bed075d27..539cf3d39 100644 --- a/gossipd/gossipd.c +++ b/gossipd/gossipd.c @@ -52,8 +52,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -1454,7 +1454,7 @@ static void dump_gossip(struct peer *peer) * sets the UPDATE bit in the error type. lightningd is too important to * fetch this itself, so channeld does it (channeld has to talk to us for * other things anyway, so why not?). */ -static bool handle_get_update(struct peer *peer, const u8 *msg) +static bool handle_get_local_channel_update(struct peer *peer, const u8 *msg) { struct short_channel_id scid; struct local_chan *local_chan; @@ -1572,7 +1572,7 @@ static struct io_plan *peer_msg_in(struct io_conn *conn, /* Must be a gossip_peerd_wire_type asking us to do something. */ switch ((enum gossip_peerd_wire_type)fromwire_peektype(msg)) { case WIRE_GOSSIPD_GET_UPDATE: - ok = handle_get_update(peer, msg); + ok = handle_get_local_channel_update(peer, msg); goto handled_cmd; case WIRE_GOSSIPD_LOCAL_ADD_CHANNEL: ok = handle_local_add_channel(peer->daemon->rstate, msg, 0); diff --git a/gossipd/routing.c b/gossipd/routing.c index b82895cca..70a1b6c51 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include @@ -485,8 +485,8 @@ static void destroy_local_chan(struct local_chan *local_chan, abort(); } -static struct local_chan *new_local_chan(struct routing_state *rstate, - struct chan *chan) +static void maybe_add_local_chan(struct routing_state *rstate, + struct chan *chan) { int direction; struct local_chan *local_chan; @@ -496,7 +496,7 @@ static struct local_chan *new_local_chan(struct routing_state *rstate, else if (node_id_eq(&chan->nodes[1]->id, &rstate->local_id)) direction = 1; else - return NULL; + return; local_chan = tal(chan, struct local_chan); local_chan->chan = chan; @@ -506,7 +506,6 @@ static struct local_chan *new_local_chan(struct routing_state *rstate, local_chan_map_add(&rstate->local_chan_map, local_chan); tal_add_destructor2(local_chan, destroy_local_chan, rstate); - return local_chan; } struct chan *new_chan(struct routing_state *rstate, @@ -551,7 +550,7 @@ struct chan *new_chan(struct routing_state *rstate, uintmap_add(&rstate->chanmap, scid->u64, chan); /* Initialize shadow structure if it's local */ - new_local_chan(rstate, chan); + maybe_add_local_chan(rstate, chan); return chan; } diff --git a/gossipd/test/run-crc32_of_update.c b/gossipd/test/run-crc32_of_update.c index 126779e1e..884c0760f 100644 --- a/gossipd/test/run-crc32_of_update.c +++ b/gossipd/test/run-crc32_of_update.c @@ -1,7 +1,7 @@ int unused_main(int argc, char *argv[]); #define main unused_main #include "../gossipd.c" -#include "../make_gossip.c" +#include "../gossip_generation.c" #undef main #include