mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 01:24:26 +01:00
connectd: divert gossip messages directly to gossipd.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <bitcoin/chainparams.h>
|
||||
#include <ccan/io/io.h>
|
||||
#include <common/cryptomsg.h>
|
||||
#include <common/daemon_conn.h>
|
||||
#include <common/dev_disconnect.h>
|
||||
#include <common/features.h>
|
||||
#include <common/gossip_constants.h>
|
||||
@@ -18,6 +19,7 @@
|
||||
#include <common/utils.h>
|
||||
#include <common/wire_error.h>
|
||||
#include <connectd/connectd.h>
|
||||
#include <connectd/connectd_gossipd_wiregen.h>
|
||||
#include <connectd/multiplex.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
@@ -29,6 +31,7 @@
|
||||
#include <wire/peer_wire.h>
|
||||
#include <wire/wire.h>
|
||||
#include <wire/wire_io.h>
|
||||
#include <wire/wire_sync.h>
|
||||
|
||||
void queue_peer_msg(struct peer *peer, const u8 *msg TAKES)
|
||||
{
|
||||
@@ -334,7 +337,7 @@ again:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* We only handle gossip_timestamp_filter for now */
|
||||
/* We handle gossip_timestamp_filter, and divert other gossip msgs to gossipd */
|
||||
static bool handle_message_locally(struct peer *peer, const u8 *msg)
|
||||
{
|
||||
struct bitcoin_blkid chain_hash;
|
||||
@@ -347,6 +350,18 @@ static bool handle_message_locally(struct peer *peer, const u8 *msg)
|
||||
if (!fromwire_gossip_timestamp_filter(msg, &chain_hash,
|
||||
&first_timestamp,
|
||||
×tamp_range)) {
|
||||
/* Do we want to divert to gossipd? */
|
||||
if (is_msg_for_gossipd(msg)) {
|
||||
u8 *gmsg = towire_gossipd_recv_gossip(NULL,
|
||||
&peer->id, msg);
|
||||
|
||||
/* gossipd doesn't log IO, so we log it here. */
|
||||
status_peer_io(LOG_IO_IN, &peer->id, msg);
|
||||
|
||||
daemon_conn_send(peer->daemon->gossipd, take(gmsg));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user