mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-23 15:04:19 +01:00
gossipd: handle ping messages for remote peers too.
This simplifies our ping handling: make gossipd always do it. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
#include <common/crypto_sync.h>
|
||||
#include <common/peer_failed.h>
|
||||
#include <common/ping.h>
|
||||
#include <common/read_peer_msg.h>
|
||||
#include <common/status.h>
|
||||
#include <common/type_to_string.h>
|
||||
@@ -12,32 +11,6 @@
|
||||
#include <wire/peer_wire.h>
|
||||
#include <wire/wire_sync.h>
|
||||
|
||||
static void handle_ping(const u8 *msg,
|
||||
int peer_fd,
|
||||
struct crypto_state *cs,
|
||||
const struct channel_id *channel,
|
||||
bool (*send_reply)(struct crypto_state *, int,
|
||||
const u8 *, void *),
|
||||
void *arg)
|
||||
{
|
||||
u8 *pong;
|
||||
|
||||
if (!check_ping_make_pong(msg, msg, &pong)) {
|
||||
send_reply(cs, peer_fd,
|
||||
take(towire_errorfmt(NULL, channel,
|
||||
"Bad ping %s",
|
||||
tal_hex(msg, msg))), arg);
|
||||
peer_failed_connection_lost();
|
||||
}
|
||||
|
||||
status_debug("Got ping, sending %s", pong ?
|
||||
wire_type_name(fromwire_peektype(pong))
|
||||
: "nothing");
|
||||
|
||||
if (pong && !send_reply(cs, peer_fd, pong, arg))
|
||||
peer_failed_connection_lost();
|
||||
}
|
||||
|
||||
void handle_gossip_msg_(const u8 *msg TAKES, int peer_fd,
|
||||
struct crypto_state *cs,
|
||||
bool (*send_msg)(struct crypto_state *cs, int fd,
|
||||
@@ -111,11 +84,6 @@ u8 *read_peer_msg_(const tal_t *ctx,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (fromwire_peektype(msg) == WIRE_PING) {
|
||||
handle_ping(msg, peer_fd, cs, channel, send_reply, arg);
|
||||
return tal_free(msg);
|
||||
}
|
||||
|
||||
if (fromwire_peektype(msg) == WIRE_ERROR) {
|
||||
char *err = sanitize_error(msg, msg, &chanid);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user