From 0d442b5ff22b8d2eae852d7a6cdb2569e1dd4905 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 24 Jul 2018 15:48:58 +0930 Subject: [PATCH] gossipd: move files into connectd. These source files are only used for peer-related things, so move them. Signed-off-by: Rusty Russell --- connectd/Makefile | 8 +++--- connectd/connect.c | 8 +++--- {gossipd => connectd}/handshake.c | 2 +- {gossipd => connectd}/handshake.h | 6 ++--- {gossipd => connectd}/netaddress.c | 2 +- {gossipd => connectd}/netaddress.h | 6 ++--- connectd/test/Makefile | 26 +++++++++++++++++++ .../test/run-initiator-success.c | 0 .../test/run-responder-success.c | 0 {gossipd => connectd}/tor.c | 4 +-- {gossipd => connectd}/tor.h | 6 ++--- {gossipd => connectd}/tor_autoservice.c | 2 +- {gossipd => connectd}/tor_autoservice.h | 6 ++--- gossipd/gossip.c | 4 --- 14 files changed, 51 insertions(+), 29 deletions(-) rename {gossipd => connectd}/handshake.c (99%) rename {gossipd => connectd}/handshake.h (92%) rename {gossipd => connectd}/netaddress.c (99%) rename {gossipd => connectd}/netaddress.h (72%) create mode 100644 connectd/test/Makefile rename {gossipd => connectd}/test/run-initiator-success.c (100%) rename {gossipd => connectd}/test/run-responder-success.c (100%) rename {gossipd => connectd}/tor.c (98%) rename {gossipd => connectd}/tor.h (73%) rename {gossipd => connectd}/tor_autoservice.c (99%) rename {gossipd => connectd}/tor_autoservice.h (68%) diff --git a/connectd/Makefile b/connectd/Makefile index 20ca4ac04..0709a6511 100644 --- a/connectd/Makefile +++ b/connectd/Makefile @@ -15,10 +15,10 @@ LIGHTNINGD_CONNECT_CONTROL_OBJS := $(LIGHTNINGD_CONNECT_CONTROL_SRC:.c=.o) LIGHTNINGD_CONNECT_HEADERS := connectd/gen_connect_wire.h \ connectd/gen_connect_gossip_wire.h \ connectd/connect.h \ - gossipd/handshake.h \ - gossipd/netaddress.h \ - gossipd/tor_autoservice.h \ - gossipd/tor.h + connectd/handshake.h \ + connectd/netaddress.h \ + connectd/tor_autoservice.h \ + connectd/tor.h LIGHTNINGD_CONNECT_SRC := $(LIGHTNINGD_CONNECT_HEADERS:.h=.c) LIGHTNINGD_CONNECT_OBJS := $(LIGHTNINGD_CONNECT_SRC:.c=.o) diff --git a/connectd/connect.c b/connectd/connect.c index af1000784..d98412457 100644 --- a/connectd/connect.c +++ b/connectd/connect.c @@ -33,12 +33,12 @@ #include #include #include +#include +#include +#include +#include #include #include -#include -#include -#include -#include #include #include #include diff --git a/gossipd/handshake.c b/connectd/handshake.c similarity index 99% rename from gossipd/handshake.c rename to connectd/handshake.c index e5be62e2b..296e0a4fa 100644 --- a/gossipd/handshake.c +++ b/connectd/handshake.c @@ -11,8 +11,8 @@ #include #include #include +#include #include -#include #include #include #include diff --git a/gossipd/handshake.h b/connectd/handshake.h similarity index 92% rename from gossipd/handshake.h rename to connectd/handshake.h index 6bc07db32..2e501dd8f 100644 --- a/gossipd/handshake.h +++ b/connectd/handshake.h @@ -1,5 +1,5 @@ -#ifndef LIGHTNING_GOSSIPD_HANDSHAKE_H -#define LIGHTNING_GOSSIPD_HANDSHAKE_H +#ifndef LIGHTNING_CONNECTD_HANDSHAKE_H +#define LIGHTNING_CONNECTD_HANDSHAKE_H #include "config.h" #include @@ -51,4 +51,4 @@ struct io_plan *responder_handshake_(struct io_conn *conn, void *cbarg), void *cbarg); -#endif /* LIGHTNING_GOSSIPD_HANDSHAKE_H */ +#endif /* LIGHTNING_CONNECTD_HANDSHAKE_H */ diff --git a/gossipd/netaddress.c b/connectd/netaddress.c similarity index 99% rename from gossipd/netaddress.c rename to connectd/netaddress.c index 8255e343b..5a9737e78 100644 --- a/gossipd/netaddress.c +++ b/connectd/netaddress.c @@ -2,8 +2,8 @@ #include #include #include +#include #include -#include #include #include #include diff --git a/gossipd/netaddress.h b/connectd/netaddress.h similarity index 72% rename from gossipd/netaddress.h rename to connectd/netaddress.h index 27ce71853..3f82d4d78 100644 --- a/gossipd/netaddress.h +++ b/connectd/netaddress.h @@ -1,5 +1,5 @@ -#ifndef LIGHTNING_GOSSIPD_NETADDRESS_H -#define LIGHTNING_GOSSIPD_NETADDRESS_H +#ifndef LIGHTNING_CONNECTD_NETADDRESS_H +#define LIGHTNING_CONNECTD_NETADDRESS_H #include "config.h" #include #include @@ -11,4 +11,4 @@ bool guess_address(struct wireaddr *wireaddr); bool address_routable(const struct wireaddr *wireaddr, bool allow_localhost); -#endif /* LIGHTNING_GOSSIPD_NETADDRESS_H */ +#endif /* LIGHTNING_CONNECTD_NETADDRESS_H */ diff --git a/connectd/test/Makefile b/connectd/test/Makefile new file mode 100644 index 000000000..6cf654dcd --- /dev/null +++ b/connectd/test/Makefile @@ -0,0 +1,26 @@ +check: connectd-tests + +# Note that these actually #include everything they need, except ccan/ and bitcoin/. +# That allows for unit testing of statics, and special effects. +CONNECTD_TEST_SRC := $(wildcard connectd/test/run-*.c) +CONNECTD_TEST_OBJS := $(CONNECTD_TEST_SRC:.c=.o) +CONNECTD_TEST_PROGRAMS := $(CONNECTD_TEST_OBJS:.o=) + +CONNECTD_TEST_COMMON_OBJS := \ + common/features.o \ + common/pseudorand.o \ + common/type_to_string.o \ + common/utils.o + +update-mocks: $(CONNECTD_TEST_SRC:%=update-mocks/%) + +$(CONNECTD_TEST_PROGRAMS): $(CONNECTD_TEST_COMMON_OBJS) $(BITCOIN_OBJS) + +# Test objects depend on ../ src and headers. +$(CONNECTD_TEST_OBJS): $(LIGHTNINGD_CONNECT_HEADERS) $(LIGHTNINGD_CONNECT_SRC) + +ALL_OBJS += $(CONNECTD_TEST_OBJS) +ALL_TEST_PROGRAMS += $(CONNECTD_TEST_PROGRAMS) + +connectd-tests: $(CONNECTD_TEST_PROGRAMS:%=unittest/%) + diff --git a/gossipd/test/run-initiator-success.c b/connectd/test/run-initiator-success.c similarity index 100% rename from gossipd/test/run-initiator-success.c rename to connectd/test/run-initiator-success.c diff --git a/gossipd/test/run-responder-success.c b/connectd/test/run-responder-success.c similarity index 100% rename from gossipd/test/run-responder-success.c rename to connectd/test/run-responder-success.c diff --git a/gossipd/tor.c b/connectd/tor.c similarity index 98% rename from gossipd/tor.c rename to connectd/tor.c index 65856a4a5..88611298a 100644 --- a/gossipd/tor.c +++ b/connectd/tor.c @@ -4,8 +4,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/gossipd/tor.h b/connectd/tor.h similarity index 73% rename from gossipd/tor.h rename to connectd/tor.h index b265b753d..0cc5b65fd 100644 --- a/gossipd/tor.h +++ b/connectd/tor.h @@ -1,5 +1,5 @@ -#ifndef LIGHTNING_GOSSIPD_TOR_H -#define LIGHTNING_GOSSIPD_TOR_H +#ifndef LIGHTNING_CONNECTD_TOR_H +#define LIGHTNING_CONNECTD_TOR_H #include "config.h" #include @@ -13,4 +13,4 @@ struct io_plan *io_tor_connect(struct io_conn *conn, const char *host, u16 port, struct reaching *reach); -#endif /* LIGHTNING_GOSSIPD_TOR_H */ +#endif /* LIGHTNING_CONNECTD_TOR_H */ diff --git a/gossipd/tor_autoservice.c b/connectd/tor_autoservice.c similarity index 99% rename from gossipd/tor_autoservice.c rename to connectd/tor_autoservice.c index 48154534c..6f50d8aff 100644 --- a/gossipd/tor_autoservice.c +++ b/connectd/tor_autoservice.c @@ -10,9 +10,9 @@ #include #include #include +#include #include #include -#include #include #include #include diff --git a/gossipd/tor_autoservice.h b/connectd/tor_autoservice.h similarity index 68% rename from gossipd/tor_autoservice.h rename to connectd/tor_autoservice.h index d792df4c6..0fc85ca55 100644 --- a/gossipd/tor_autoservice.h +++ b/connectd/tor_autoservice.h @@ -1,5 +1,5 @@ -#ifndef LIGHTNING_GOSSIPD_TOR_AUTOSERVICE_H -#define LIGHTNING_GOSSIPD_TOR_AUTOSERVICE_H +#ifndef LIGHTNING_CONNECTD_TOR_AUTOSERVICE_H +#define LIGHTNING_CONNECTD_TOR_AUTOSERVICE_H #include "config.h" #include #include @@ -11,4 +11,4 @@ struct wireaddr *tor_autoservice(const tal_t *ctx, const char *tor_password, const struct wireaddr_internal *bindings); -#endif /* LIGHTNING_GOSSIPD_TOR_AUTOSERVICE_H */ +#endif /* LIGHTNING_CONNECTD_TOR_AUTOSERVICE_H */ diff --git a/gossipd/gossip.c b/gossipd/gossip.c index 296d8355c..338871ef7 100644 --- a/gossipd/gossip.c +++ b/gossipd/gossip.c @@ -36,11 +36,7 @@ #include #include #include -#include -#include #include -#include -#include #include #include #include