Skip to content

Commit

Permalink
common/read_peer_msg: handle pings in handle_peer_gossip_or_error().
Browse files Browse the repository at this point in the history
This is a noop for now, since gossipd handles them.  But that
will change in the next patch.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell authored and cdecker committed Oct 10, 2021
1 parent 6dc7fc6 commit c394fd5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions closingd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ CLOSINGD_COMMON_OBJS := \
common/peer_failed.o \
common/per_peer_state.o \
common/permute_tx.o \
common/ping.o \
common/psbt_open.o \
common/pseudorand.o \
common/read_peer_msg.o \
Expand Down
8 changes: 7 additions & 1 deletion common/read_peer_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <common/gossip_store.h>
#include <common/peer_failed.h>
#include <common/per_peer_state.h>
#include <common/ping.h>
#include <common/read_peer_msg.h>
#include <common/status.h>
#include <common/wire_error.h>
Expand Down Expand Up @@ -156,6 +157,7 @@ bool handle_peer_gossip_or_error(struct per_peer_state *pps,
{
char *err;
bool warning;
u8 *pong;

#if DEVELOPER
/* Any odd-typed unknown message is handled by the caller, so if we
Expand All @@ -174,7 +176,11 @@ bool handle_peer_gossip_or_error(struct per_peer_state *pps,

if (handle_timestamp_filter(pps, msg))
return true;
else if (is_msg_for_gossipd(msg)) {
else if (check_ping_make_pong(NULL, msg, &pong)) {
if (pong)
sync_crypto_write(pps, take(pong));
return true;
} else if (is_msg_for_gossipd(msg)) {
gossip_rcvd_filter_add(pps->grf, msg);
wire_sync_write(pps->gossip_fd, msg);
/* wire_sync_write takes, so don't take again. */
Expand Down
2 changes: 1 addition & 1 deletion common/read_peer_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ bool is_wrong_channel(const u8 *msg, const struct channel_id *expected,
*
* This returns true if it handled the packet: a gossip packet (forwarded
* to gossipd), or an error packet (causes peer_failed_received_errmsg or
* ignored).
* ignored), or a ping (may reply with pong).
*/
bool handle_peer_gossip_or_error(struct per_peer_state *pps,
const struct channel_id *channel_id,
Expand Down
1 change: 1 addition & 0 deletions openingd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ OPENINGD_COMMON_OBJS := \
common/peer_billboard.o \
common/peer_failed.o \
common/permute_tx.o \
common/ping.o \
common/psbt_internal.o \
common/psbt_open.o \
common/pseudorand.o \
Expand Down

0 comments on commit c394fd5

Please sign in to comment.