mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 10:46:58 +01:00
channeld: take over gossip_rcvd_filter.c and is_msg_gossip_broadcast.
channeld is the only user of these functions, since it now streams all gossip itself. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
ecdfbbf359
commit
7c8dc62035
18 changed files with 64 additions and 74 deletions
|
@ -48,7 +48,6 @@ CHANNELD_COMMON_OBJS := \
|
||||||
common/ecdh_hsmd.o \
|
common/ecdh_hsmd.o \
|
||||||
common/features.o \
|
common/features.o \
|
||||||
common/fee_states.o \
|
common/fee_states.o \
|
||||||
common/gossip_rcvd_filter.o \
|
|
||||||
common/peer_io.o \
|
common/peer_io.o \
|
||||||
common/peer_status_wiregen.o \
|
common/peer_status_wiregen.o \
|
||||||
common/status_wiregen.o \
|
common/status_wiregen.o \
|
||||||
|
|
|
@ -30,7 +30,6 @@ CLOSINGD_COMMON_OBJS := \
|
||||||
common/daemon.o \
|
common/daemon.o \
|
||||||
common/daemon_conn.o \
|
common/daemon_conn.o \
|
||||||
common/derive_basepoints.o \
|
common/derive_basepoints.o \
|
||||||
common/gossip_rcvd_filter.o \
|
|
||||||
common/gossip_store.o \
|
common/gossip_store.o \
|
||||||
common/htlc_wire.o \
|
common/htlc_wire.o \
|
||||||
common/key_derive.o \
|
common/key_derive.o \
|
||||||
|
|
|
@ -34,7 +34,6 @@ COMMON_SRC_NOGEN := \
|
||||||
common/features.c \
|
common/features.c \
|
||||||
common/fee_states.c \
|
common/fee_states.c \
|
||||||
common/fp16.c \
|
common/fp16.c \
|
||||||
common/gossip_rcvd_filter.c \
|
|
||||||
common/gossip_store.c \
|
common/gossip_store.c \
|
||||||
common/gossmap.c \
|
common/gossmap.c \
|
||||||
common/hash_u5.c \
|
common/hash_u5.c \
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <ccan/crc32c/crc32c.h>
|
#include <ccan/crc32c/crc32c.h>
|
||||||
#include <common/gossip_rcvd_filter.h>
|
|
||||||
#include <common/gossip_store.h>
|
#include <common/gossip_store.h>
|
||||||
#include <common/per_peer_state.h>
|
#include <common/per_peer_state.h>
|
||||||
#include <common/status.h>
|
#include <common/status.h>
|
||||||
|
|
|
@ -5,6 +5,7 @@ CONNECTD_HEADERS := connectd/connectd_wiregen.h \
|
||||||
connectd/connectd.h \
|
connectd/connectd.h \
|
||||||
connectd/peer_exchange_initmsg.h \
|
connectd/peer_exchange_initmsg.h \
|
||||||
connectd/handshake.h \
|
connectd/handshake.h \
|
||||||
|
connectd/gossip_rcvd_filter.h \
|
||||||
connectd/multiplex.h \
|
connectd/multiplex.h \
|
||||||
connectd/netaddress.h \
|
connectd/netaddress.h \
|
||||||
connectd/onion_message.h \
|
connectd/onion_message.h \
|
||||||
|
@ -55,7 +56,6 @@ CONNECTD_COMMON_OBJS := \
|
||||||
common/hmac.o \
|
common/hmac.o \
|
||||||
common/status_wiregen.o \
|
common/status_wiregen.o \
|
||||||
common/gossip_store.o \
|
common/gossip_store.o \
|
||||||
common/gossip_rcvd_filter.o \
|
|
||||||
common/key_derive.o \
|
common/key_derive.o \
|
||||||
common/memleak.o \
|
common/memleak.o \
|
||||||
common/msg_queue.o \
|
common/msg_queue.o \
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
#include <common/daemon_conn.h>
|
#include <common/daemon_conn.h>
|
||||||
#include <common/dev_disconnect.h>
|
#include <common/dev_disconnect.h>
|
||||||
#include <common/ecdh_hsmd.h>
|
#include <common/ecdh_hsmd.h>
|
||||||
#include <common/gossip_rcvd_filter.h>
|
|
||||||
#include <common/gossip_store.h>
|
#include <common/gossip_store.h>
|
||||||
#include <common/jsonrpc_errors.h>
|
#include <common/jsonrpc_errors.h>
|
||||||
#include <common/memleak.h>
|
#include <common/memleak.h>
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <ccan/crypto/siphash24/siphash24.h>
|
#include <ccan/crypto/siphash24/siphash24.h>
|
||||||
#include <ccan/htable/htable.h>
|
#include <ccan/htable/htable.h>
|
||||||
#include <common/gossip_rcvd_filter.h>
|
|
||||||
#include <common/memleak.h>
|
#include <common/memleak.h>
|
||||||
#include <common/pseudorand.h>
|
#include <common/pseudorand.h>
|
||||||
|
#include <connectd/gossip_rcvd_filter.h>
|
||||||
#include <wire/peer_wire.h>
|
#include <wire/peer_wire.h>
|
||||||
|
|
||||||
static u64 msg_key(const u8 *msg)
|
static u64 msg_key(const u8 *msg)
|
|
@ -1,7 +1,7 @@
|
||||||
/* This implements a cheap gossip cache, so we can recognize what gossip
|
/* This implements a cheap gossip cache, so we can recognize what gossip
|
||||||
* msgs this peer sent us, thus avoid retransmitting gossip it sent. */
|
* msgs this peer sent us, thus avoid retransmitting gossip it sent. */
|
||||||
#ifndef LIGHTNING_COMMON_GOSSIP_RCVD_FILTER_H
|
#ifndef LIGHTNING_CONNECTD_GOSSIP_RCVD_FILTER_H
|
||||||
#define LIGHTNING_COMMON_GOSSIP_RCVD_FILTER_H
|
#define LIGHTNING_CONNECTD_GOSSIP_RCVD_FILTER_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <ccan/short_types/short_types.h>
|
#include <ccan/short_types/short_types.h>
|
||||||
#include <ccan/tal/tal.h>
|
#include <ccan/tal/tal.h>
|
||||||
|
@ -19,4 +19,4 @@ bool gossip_rcvd_filter_del(struct gossip_rcvd_filter *map, const u8 *msg);
|
||||||
/* Flush out old entries. */
|
/* Flush out old entries. */
|
||||||
void gossip_rcvd_filter_age(struct gossip_rcvd_filter *map);
|
void gossip_rcvd_filter_age(struct gossip_rcvd_filter *map);
|
||||||
|
|
||||||
#endif /* LIGHTNING_COMMON_GOSSIP_RCVD_FILTER_H */
|
#endif /* LIGHTNING_CONNECTD_GOSSIP_RCVD_FILTER_H */
|
|
@ -10,7 +10,6 @@
|
||||||
#include <common/dev_disconnect.h>
|
#include <common/dev_disconnect.h>
|
||||||
#include <common/features.h>
|
#include <common/features.h>
|
||||||
#include <common/gossip_constants.h>
|
#include <common/gossip_constants.h>
|
||||||
#include <common/gossip_rcvd_filter.h>
|
|
||||||
#include <common/gossip_store.h>
|
#include <common/gossip_store.h>
|
||||||
#include <common/memleak.h>
|
#include <common/memleak.h>
|
||||||
#include <common/per_peer_state.h>
|
#include <common/per_peer_state.h>
|
||||||
|
@ -23,6 +22,7 @@
|
||||||
#include <connectd/connectd.h>
|
#include <connectd/connectd.h>
|
||||||
#include <connectd/connectd_gossipd_wiregen.h>
|
#include <connectd/connectd_gossipd_wiregen.h>
|
||||||
#include <connectd/connectd_wiregen.h>
|
#include <connectd/connectd_wiregen.h>
|
||||||
|
#include <connectd/gossip_rcvd_filter.h>
|
||||||
#include <connectd/multiplex.h>
|
#include <connectd/multiplex.h>
|
||||||
#include <connectd/onion_message.h>
|
#include <connectd/onion_message.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -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. */
|
/* We handle pings and gossip messages. */
|
||||||
static bool handle_message_locally(struct peer *peer, const u8 *msg)
|
static bool handle_message_locally(struct peer *peer, const u8 *msg)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "../gossip_rcvd_filter.c"
|
#include "../gossip_rcvd_filter.c"
|
||||||
#include "../pseudorand.c"
|
|
||||||
#include "../../wire/fromwire.c"
|
#include "../../wire/fromwire.c"
|
||||||
|
#include <assert.h>
|
||||||
#include <common/setup.h>
|
#include <common/setup.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
@ -53,6 +53,9 @@ void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED,
|
||||||
/* Generated stub for towire_sha256 */
|
/* Generated stub for towire_sha256 */
|
||||||
void towire_sha256(u8 **pptr UNNEEDED, const struct sha256 *sha256 UNNEEDED)
|
void towire_sha256(u8 **pptr UNNEEDED, const struct sha256 *sha256 UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_sha256 called!\n"); abort(); }
|
{ 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 */
|
/* Generated stub for towire_u32 */
|
||||||
void towire_u32(u8 **pptr UNNEEDED, u32 v UNNEEDED)
|
void towire_u32(u8 **pptr UNNEEDED, u32 v UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_u32 called!\n"); abort(); }
|
{ fprintf(stderr, "towire_u32 called!\n"); abort(); }
|
|
@ -25,7 +25,6 @@ DEVTOOLS_COMMON_OBJS := \
|
||||||
common/decode_array.o \
|
common/decode_array.o \
|
||||||
common/features.o \
|
common/features.o \
|
||||||
common/fee_states.o \
|
common/fee_states.o \
|
||||||
common/gossip_rcvd_filter.o \
|
|
||||||
common/hash_u5.o \
|
common/hash_u5.o \
|
||||||
common/hmac.o \
|
common/hmac.o \
|
||||||
common/htlc_state.o \
|
common/htlc_state.o \
|
||||||
|
|
|
@ -44,7 +44,6 @@ GOSSIPD_COMMON_OBJS := \
|
||||||
common/ecdh_hsmd.o \
|
common/ecdh_hsmd.o \
|
||||||
common/features.o \
|
common/features.o \
|
||||||
common/status_wiregen.o \
|
common/status_wiregen.o \
|
||||||
common/gossip_rcvd_filter.o \
|
|
||||||
common/key_derive.o \
|
common/key_derive.o \
|
||||||
common/lease_rates.o \
|
common/lease_rates.o \
|
||||||
common/memleak.o \
|
common/memleak.o \
|
||||||
|
|
|
@ -92,7 +92,6 @@ LIGHTNINGD_COMMON_OBJS := \
|
||||||
common/peer_status_wiregen.o \
|
common/peer_status_wiregen.o \
|
||||||
common/status_levels.o \
|
common/status_levels.o \
|
||||||
common/status_wiregen.o \
|
common/status_wiregen.o \
|
||||||
common/gossip_rcvd_filter.o \
|
|
||||||
common/hash_u5.o \
|
common/hash_u5.o \
|
||||||
common/hmac.o \
|
common/hmac.o \
|
||||||
common/hsm_encryption.o \
|
common/hsm_encryption.o \
|
||||||
|
|
|
@ -47,7 +47,6 @@ OPENINGD_COMMON_OBJS := \
|
||||||
common/derive_basepoints.o \
|
common/derive_basepoints.o \
|
||||||
common/features.o \
|
common/features.o \
|
||||||
common/fee_states.o \
|
common/fee_states.o \
|
||||||
common/gossip_rcvd_filter.o \
|
|
||||||
common/gossip_store.o \
|
common/gossip_store.o \
|
||||||
common/htlc_state.o \
|
common/htlc_state.o \
|
||||||
common/htlc_wire.o \
|
common/htlc_wire.o \
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#include <common/billboard.h>
|
#include <common/billboard.h>
|
||||||
#include <common/blockheight_states.h>
|
#include <common/blockheight_states.h>
|
||||||
#include <common/channel_type.h>
|
#include <common/channel_type.h>
|
||||||
#include <common/gossip_rcvd_filter.h>
|
|
||||||
#include <common/gossip_store.h>
|
#include <common/gossip_store.h>
|
||||||
#include <common/initial_channel.h>
|
#include <common/initial_channel.h>
|
||||||
#include <common/lease_rates.h>
|
#include <common/lease_rates.h>
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <common/channel_type.h>
|
#include <common/channel_type.h>
|
||||||
#include <common/fee_states.h>
|
#include <common/fee_states.h>
|
||||||
#include <common/gossip_rcvd_filter.h>
|
|
||||||
#include <common/gossip_store.h>
|
#include <common/gossip_store.h>
|
||||||
#include <common/initial_channel.h>
|
#include <common/initial_channel.h>
|
||||||
#include <common/memleak.h>
|
#include <common/memleak.h>
|
||||||
|
|
|
@ -109,60 +109,6 @@ bool is_msg_for_gossipd(const u8 *cursor)
|
||||||
return false;
|
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. */
|
/* Return true if it's an unknown ODD message. cursor is a tal ptr. */
|
||||||
bool is_unknown_msg_discardable(const u8 *cursor)
|
bool is_unknown_msg_discardable(const u8 *cursor)
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
bool is_unknown_msg_discardable(const u8 *cursor);
|
bool is_unknown_msg_discardable(const u8 *cursor);
|
||||||
/* Return true if it's a message for gossipd. */
|
/* Return true if it's a message for gossipd. */
|
||||||
bool is_msg_for_gossipd(const u8 *cursor);
|
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. */
|
/* Extract channel_id from various packets, return true if possible. */
|
||||||
bool extract_channel_id(const u8 *in_pkt, struct channel_id *channel_id);
|
bool extract_channel_id(const u8 *in_pkt, struct channel_id *channel_id);
|
||||||
|
|
Loading…
Add table
Reference in a new issue