mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-02 12:44:26 +01:00
gossipd: don't wrap messages when we send them to the peer.
They already send *us* gossip messages, so they have to be distinct anyway. Why make us both do extra work? Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -100,11 +100,9 @@ void handle_gossip_msg(struct per_peer_state *pps, const u8 *msg TAKES)
|
||||
goto out;
|
||||
} else if (fromwire_gossipd_send_gossip_from_store(msg, &offset))
|
||||
gossip = gossip_store_read(tmpctx, pps->gossip_store_fd, offset);
|
||||
else if (!fromwire_gossipd_send_gossip(tmpctx, msg, &gossip)) {
|
||||
status_broken("Got bad message from gossipd: %s",
|
||||
tal_hex(msg, msg));
|
||||
peer_failed_connection_lost();
|
||||
}
|
||||
else
|
||||
/* It's a raw gossip msg: this copies or takes() */
|
||||
gossip = tal_dup_arr(tmpctx, u8, msg, tal_bytelen(msg), 0);
|
||||
|
||||
/* Gossipd can send us gossip messages, OR errors */
|
||||
if (is_msg_for_gossipd(gossip)) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# These must be distinct from WIRE_CHANNEL_ANNOUNCEMENT etc. gossip msgs!
|
||||
# Channel daemon can ask for updates for a specific channel, for sending
|
||||
# errors. Must be distinct from WIRE_CHANNEL_ANNOUNCEMENT etc. gossip msgs!
|
||||
# errors.
|
||||
gossipd_get_update,3501
|
||||
gossipd_get_update,,short_channel_id,struct short_channel_id
|
||||
|
||||
@@ -8,11 +9,6 @@ gossipd_get_update_reply,3601
|
||||
gossipd_get_update_reply,,len,u16
|
||||
gossipd_get_update_reply,,update,len*u8
|
||||
|
||||
# Gossipd can tell channeld etc about raw messages to fwd.
|
||||
gossipd_send_gossip,3502
|
||||
gossipd_send_gossip,,len,u16
|
||||
gossipd_send_gossip,,gossip,len*u8
|
||||
|
||||
# But usually gossipd just gives an offset into the gossip_store
|
||||
gossipd_send_gossip_from_store,3506
|
||||
gossipd_send_gossip_from_store,,offset,u64
|
||||
|
||||
|
@@ -221,18 +221,11 @@ static struct peer *find_peer(struct daemon *daemon, const struct node_id *id)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Queue a gossip message for the peer: we wrap every gossip message; the
|
||||
* subdaemon simply unwraps and sends. Note that we don't wrap messages
|
||||
* coming from the subdaemon to gossipd, because gossipd has to process the
|
||||
* messages anyway (and it doesn't trust the subdaemon); the subdaemon
|
||||
* trusts gossipd and will forward whatever it's told to. */
|
||||
/* Queue a gossip message for the peer: the subdaemon on the other end simply
|
||||
* forwards it to the peer. */
|
||||
static void queue_peer_msg(struct peer *peer, const u8 *msg TAKES)
|
||||
{
|
||||
const u8 *send = towire_gossipd_send_gossip(NULL, msg);
|
||||
/* Autogenerated functions don't take(), so we do here */
|
||||
if (taken(msg))
|
||||
tal_free(msg);
|
||||
daemon_conn_send(peer->dc, take(send));
|
||||
daemon_conn_send(peer->dc, msg);
|
||||
}
|
||||
|
||||
/*~ We have a shortcut for messages from the store: we send the offset, and
|
||||
@@ -1681,7 +1674,6 @@ static struct io_plan *peer_msg_in(struct io_conn *conn,
|
||||
|
||||
/* These are the ones we send, not them */
|
||||
case WIRE_GOSSIPD_GET_UPDATE_REPLY:
|
||||
case WIRE_GOSSIPD_SEND_GOSSIP:
|
||||
case WIRE_GOSSIPD_NEW_STORE_FD:
|
||||
case WIRE_GOSSIPD_SEND_GOSSIP_FROM_STORE:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user