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:
Rusty Russell
2019-06-04 03:42:25 +09:30
parent 38d2899fbb
commit a5f6ef385a
3 changed files with 8 additions and 22 deletions

View File

@@ -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)) {

View File

@@ -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
1 # Channel daemon can ask for updates for a specific channel, for sending # These must be distinct from WIRE_CHANNEL_ANNOUNCEMENT etc. gossip msgs!
1 # These must be distinct from WIRE_CHANNEL_ANNOUNCEMENT etc. gossip msgs!
2 # Channel daemon can ask for updates for a specific channel, for sending # Channel daemon can ask for updates for a specific channel, for sending
3 # errors. Must be distinct from WIRE_CHANNEL_ANNOUNCEMENT etc. gossip msgs! # errors.
4 gossipd_get_update,3501 gossipd_get_update,3501
5 gossipd_get_update,,short_channel_id,struct short_channel_id gossipd_get_update,,short_channel_id,struct short_channel_id
6 # If channel isn't known, update will be empty. # If channel isn't known, update will be empty.
9 gossipd_get_update_reply,,update,len*u8 gossipd_get_update_reply,,update,len*u8
10 # Gossipd can tell channeld etc about raw messages to fwd. # But usually gossipd just gives an offset into the gossip_store
11 gossipd_send_gossip,3502 gossipd_send_gossip_from_store,3506
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
12 # Both sides have seen the funding tx being locked, but we have not gossipd_send_gossip_from_store,,offset,u64
13 # yet reached the announcement depth. So we add the channel locally so # Both sides have seen the funding tx being locked, but we have not
14 # we (and peer) can update it already. # yet reached the announcement depth. So we add the channel locally so

View File

@@ -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;