diff --git a/channeld/Makefile b/channeld/Makefile index bdab8ffa0..1b9a7317c 100644 --- a/channeld/Makefile +++ b/channeld/Makefile @@ -48,7 +48,6 @@ CHANNELD_COMMON_OBJS := \ common/ecdh_hsmd.o \ common/features.o \ common/fee_states.o \ - common/gossip_rcvd_filter.o \ common/peer_io.o \ common/peer_status_wiregen.o \ common/status_wiregen.o \ diff --git a/closingd/Makefile b/closingd/Makefile index 7ee284fbb..b7da71f42 100644 --- a/closingd/Makefile +++ b/closingd/Makefile @@ -30,7 +30,6 @@ CLOSINGD_COMMON_OBJS := \ common/daemon.o \ common/daemon_conn.o \ common/derive_basepoints.o \ - common/gossip_rcvd_filter.o \ common/gossip_store.o \ common/htlc_wire.o \ common/key_derive.o \ diff --git a/common/Makefile b/common/Makefile index 86f1588b4..3665baf4f 100644 --- a/common/Makefile +++ b/common/Makefile @@ -34,7 +34,6 @@ COMMON_SRC_NOGEN := \ common/features.c \ common/fee_states.c \ common/fp16.c \ - common/gossip_rcvd_filter.c \ common/gossip_store.c \ common/gossmap.c \ common/hash_u5.c \ diff --git a/common/gossip_store.c b/common/gossip_store.c index eba8a5ab0..b36897aca 100644 --- a/common/gossip_store.c +++ b/common/gossip_store.c @@ -1,6 +1,5 @@ #include "config.h" #include -#include #include #include #include diff --git a/connectd/Makefile b/connectd/Makefile index 8b1ea8907..684349c41 100644 --- a/connectd/Makefile +++ b/connectd/Makefile @@ -5,6 +5,7 @@ CONNECTD_HEADERS := connectd/connectd_wiregen.h \ connectd/connectd.h \ connectd/peer_exchange_initmsg.h \ connectd/handshake.h \ + connectd/gossip_rcvd_filter.h \ connectd/multiplex.h \ connectd/netaddress.h \ connectd/onion_message.h \ @@ -55,7 +56,6 @@ CONNECTD_COMMON_OBJS := \ common/hmac.o \ common/status_wiregen.o \ common/gossip_store.o \ - common/gossip_rcvd_filter.o \ common/key_derive.o \ common/memleak.o \ common/msg_queue.o \ diff --git a/connectd/connectd.c b/connectd/connectd.c index e20bf7f7f..13a4bffbe 100644 --- a/connectd/connectd.c +++ b/connectd/connectd.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include diff --git a/common/gossip_rcvd_filter.c b/connectd/gossip_rcvd_filter.c similarity index 98% rename from common/gossip_rcvd_filter.c rename to connectd/gossip_rcvd_filter.c index 0c6b3d350..914bd03f8 100644 --- a/common/gossip_rcvd_filter.c +++ b/connectd/gossip_rcvd_filter.c @@ -1,9 +1,9 @@ #include "config.h" #include #include -#include #include #include +#include #include static u64 msg_key(const u8 *msg) diff --git a/common/gossip_rcvd_filter.h b/connectd/gossip_rcvd_filter.h similarity index 81% rename from common/gossip_rcvd_filter.h rename to connectd/gossip_rcvd_filter.h index a2495efa4..1a7d0a21c 100644 --- a/common/gossip_rcvd_filter.h +++ b/connectd/gossip_rcvd_filter.h @@ -1,7 +1,7 @@ /* This implements a cheap gossip cache, so we can recognize what gossip * msgs this peer sent us, thus avoid retransmitting gossip it sent. */ -#ifndef LIGHTNING_COMMON_GOSSIP_RCVD_FILTER_H -#define LIGHTNING_COMMON_GOSSIP_RCVD_FILTER_H +#ifndef LIGHTNING_CONNECTD_GOSSIP_RCVD_FILTER_H +#define LIGHTNING_CONNECTD_GOSSIP_RCVD_FILTER_H #include "config.h" #include #include @@ -19,4 +19,4 @@ bool gossip_rcvd_filter_del(struct gossip_rcvd_filter *map, const u8 *msg); /* Flush out old entries. */ void gossip_rcvd_filter_age(struct gossip_rcvd_filter *map); -#endif /* LIGHTNING_COMMON_GOSSIP_RCVD_FILTER_H */ +#endif /* LIGHTNING_CONNECTD_GOSSIP_RCVD_FILTER_H */ diff --git a/connectd/multiplex.c b/connectd/multiplex.c index 1f50ab683..331d1b680 100644 --- a/connectd/multiplex.c +++ b/connectd/multiplex.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -23,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -640,6 +640,60 @@ static bool handle_custommsg(struct daemon *daemon, } } +static bool is_msg_gossip_broadcast(const u8 *cursor) +{ + switch ((enum peer_wire)fromwire_peektype(cursor)) { + case WIRE_CHANNEL_ANNOUNCEMENT: + case WIRE_NODE_ANNOUNCEMENT: + case WIRE_CHANNEL_UPDATE: + return true; + case WIRE_QUERY_SHORT_CHANNEL_IDS: + case WIRE_REPLY_SHORT_CHANNEL_IDS_END: + case WIRE_QUERY_CHANNEL_RANGE: + case WIRE_REPLY_CHANNEL_RANGE: + case WIRE_ONION_MESSAGE: + case WIRE_OBS2_ONION_MESSAGE: + case WIRE_WARNING: + case WIRE_INIT: + case WIRE_PING: + case WIRE_PONG: + case WIRE_ERROR: + case WIRE_OPEN_CHANNEL: + case WIRE_ACCEPT_CHANNEL: + case WIRE_FUNDING_CREATED: + case WIRE_FUNDING_SIGNED: + case WIRE_FUNDING_LOCKED: + case WIRE_SHUTDOWN: + case WIRE_CLOSING_SIGNED: + case WIRE_UPDATE_ADD_HTLC: + case WIRE_UPDATE_FULFILL_HTLC: + case WIRE_UPDATE_FAIL_HTLC: + case WIRE_UPDATE_FAIL_MALFORMED_HTLC: + case WIRE_COMMITMENT_SIGNED: + case WIRE_REVOKE_AND_ACK: + case WIRE_UPDATE_FEE: + case WIRE_UPDATE_BLOCKHEIGHT: + case WIRE_CHANNEL_REESTABLISH: + case WIRE_ANNOUNCEMENT_SIGNATURES: + case WIRE_GOSSIP_TIMESTAMP_FILTER: + case WIRE_TX_ADD_INPUT: + case WIRE_TX_REMOVE_INPUT: + case WIRE_TX_ADD_OUTPUT: + case WIRE_TX_REMOVE_OUTPUT: + case WIRE_TX_COMPLETE: + case WIRE_TX_SIGNATURES: + case WIRE_OPEN_CHANNEL2: + case WIRE_ACCEPT_CHANNEL2: + case WIRE_INIT_RBF: + case WIRE_ACK_RBF: +#if EXPERIMENTAL_FEATURES + case WIRE_STFU: +#endif + break; + } + return false; +} + /* We handle pings and gossip messages. */ static bool handle_message_locally(struct peer *peer, const u8 *msg) { diff --git a/common/test/run-gossip_rcvd_filter.c b/connectd/test/run-gossip_rcvd_filter.c similarity index 98% rename from common/test/run-gossip_rcvd_filter.c rename to connectd/test/run-gossip_rcvd_filter.c index 473229bde..7a6dfd3db 100644 --- a/common/test/run-gossip_rcvd_filter.c +++ b/connectd/test/run-gossip_rcvd_filter.c @@ -1,7 +1,7 @@ #include "config.h" #include "../gossip_rcvd_filter.c" -#include "../pseudorand.c" #include "../../wire/fromwire.c" +#include #include #include @@ -53,6 +53,9 @@ void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED, /* Generated stub for towire_sha256 */ void towire_sha256(u8 **pptr UNNEEDED, const struct sha256 *sha256 UNNEEDED) { fprintf(stderr, "towire_sha256 called!\n"); abort(); } +/* Generated stub for towire_u16 */ +void towire_u16(u8 **pptr UNNEEDED, u16 v UNNEEDED) +{ fprintf(stderr, "towire_u16 called!\n"); abort(); } /* Generated stub for towire_u32 */ void towire_u32(u8 **pptr UNNEEDED, u32 v UNNEEDED) { fprintf(stderr, "towire_u32 called!\n"); abort(); } diff --git a/devtools/Makefile b/devtools/Makefile index ba529da0f..35ba6da51 100644 --- a/devtools/Makefile +++ b/devtools/Makefile @@ -25,7 +25,6 @@ DEVTOOLS_COMMON_OBJS := \ common/decode_array.o \ common/features.o \ common/fee_states.o \ - common/gossip_rcvd_filter.o \ common/hash_u5.o \ common/hmac.o \ common/htlc_state.o \ diff --git a/gossipd/Makefile b/gossipd/Makefile index c31f3486c..2a2b8a40f 100644 --- a/gossipd/Makefile +++ b/gossipd/Makefile @@ -44,7 +44,6 @@ GOSSIPD_COMMON_OBJS := \ common/ecdh_hsmd.o \ common/features.o \ common/status_wiregen.o \ - common/gossip_rcvd_filter.o \ common/key_derive.o \ common/lease_rates.o \ common/memleak.o \ diff --git a/lightningd/Makefile b/lightningd/Makefile index 8876dc55c..f1f1607ea 100644 --- a/lightningd/Makefile +++ b/lightningd/Makefile @@ -92,7 +92,6 @@ LIGHTNINGD_COMMON_OBJS := \ common/peer_status_wiregen.o \ common/status_levels.o \ common/status_wiregen.o \ - common/gossip_rcvd_filter.o \ common/hash_u5.o \ common/hmac.o \ common/hsm_encryption.o \ diff --git a/openingd/Makefile b/openingd/Makefile index 608268399..1da236ac3 100644 --- a/openingd/Makefile +++ b/openingd/Makefile @@ -47,7 +47,6 @@ OPENINGD_COMMON_OBJS := \ common/derive_basepoints.o \ common/features.o \ common/fee_states.o \ - common/gossip_rcvd_filter.o \ common/gossip_store.o \ common/htlc_state.o \ common/htlc_wire.o \ diff --git a/openingd/dualopend.c b/openingd/dualopend.c index 2afcc4993..8c425af01 100644 --- a/openingd/dualopend.c +++ b/openingd/dualopend.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include diff --git a/openingd/openingd.c b/openingd/openingd.c index b929a998f..8870c34d9 100644 --- a/openingd/openingd.c +++ b/openingd/openingd.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include diff --git a/wire/peer_wire.c b/wire/peer_wire.c index 35089e48f..0aca55a5d 100644 --- a/wire/peer_wire.c +++ b/wire/peer_wire.c @@ -109,60 +109,6 @@ bool is_msg_for_gossipd(const u8 *cursor) return false; } -bool is_msg_gossip_broadcast(const u8 *cursor) -{ - switch ((enum peer_wire)fromwire_peektype(cursor)) { - case WIRE_CHANNEL_ANNOUNCEMENT: - case WIRE_NODE_ANNOUNCEMENT: - case WIRE_CHANNEL_UPDATE: - return true; - case WIRE_QUERY_SHORT_CHANNEL_IDS: - case WIRE_REPLY_SHORT_CHANNEL_IDS_END: - case WIRE_QUERY_CHANNEL_RANGE: - case WIRE_REPLY_CHANNEL_RANGE: - case WIRE_ONION_MESSAGE: - case WIRE_OBS2_ONION_MESSAGE: - case WIRE_WARNING: - case WIRE_INIT: - case WIRE_PING: - case WIRE_PONG: - case WIRE_ERROR: - case WIRE_OPEN_CHANNEL: - case WIRE_ACCEPT_CHANNEL: - case WIRE_FUNDING_CREATED: - case WIRE_FUNDING_SIGNED: - case WIRE_FUNDING_LOCKED: - case WIRE_SHUTDOWN: - case WIRE_CLOSING_SIGNED: - case WIRE_UPDATE_ADD_HTLC: - case WIRE_UPDATE_FULFILL_HTLC: - case WIRE_UPDATE_FAIL_HTLC: - case WIRE_UPDATE_FAIL_MALFORMED_HTLC: - case WIRE_COMMITMENT_SIGNED: - case WIRE_REVOKE_AND_ACK: - case WIRE_UPDATE_FEE: - case WIRE_UPDATE_BLOCKHEIGHT: - case WIRE_CHANNEL_REESTABLISH: - case WIRE_ANNOUNCEMENT_SIGNATURES: - case WIRE_GOSSIP_TIMESTAMP_FILTER: - case WIRE_TX_ADD_INPUT: - case WIRE_TX_REMOVE_INPUT: - case WIRE_TX_ADD_OUTPUT: - case WIRE_TX_REMOVE_OUTPUT: - case WIRE_TX_COMPLETE: - case WIRE_TX_SIGNATURES: - case WIRE_OPEN_CHANNEL2: - case WIRE_ACCEPT_CHANNEL2: - case WIRE_INIT_RBF: - case WIRE_ACK_RBF: -#if EXPERIMENTAL_FEATURES - case WIRE_STFU: -#endif - break; - } - return false; -} - /* Return true if it's an unknown ODD message. cursor is a tal ptr. */ bool is_unknown_msg_discardable(const u8 *cursor) { diff --git a/wire/peer_wire.h b/wire/peer_wire.h index d57a84d20..12c951b8f 100644 --- a/wire/peer_wire.h +++ b/wire/peer_wire.h @@ -23,8 +23,6 @@ bool is_unknown_msg_discardable(const u8 *cursor); /* Return true if it's a message for gossipd. */ bool is_msg_for_gossipd(const u8 *cursor); -/* Return true if it's a gossip update or announcement. */ -bool is_msg_gossip_broadcast(const u8 *cursor); /* Extract channel_id from various packets, return true if possible. */ bool extract_channel_id(const u8 *in_pkt, struct channel_id *channel_id);