From d492f3872cf865b161ff6aa9ce89942a95f29907 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 27 Jun 2017 12:20:10 +0930 Subject: [PATCH] wire/peer_wire: rename gossip_msg / unknown_msg / unknown_msg_discardable The next patch includes wire/peer_wire.h and causes a compile error as lightningd/gossip_control.c defined its own gossip_msg function. New names are clearer. Signed-off-by: Rusty Russell --- lightningd/channel/channel.c | 2 +- lightningd/cryptomsg.c | 2 +- lightningd/opening/opening.c | 2 +- lightningd/test/run-cryptomsg.c | 2 +- wire/peer_wire.c | 6 +++--- wire/peer_wire.h | 6 +++--- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lightningd/channel/channel.c b/lightningd/channel/channel.c index 31cac7a62..720ab6b09 100644 --- a/lightningd/channel/channel.c +++ b/lightningd/channel/channel.c @@ -1438,7 +1438,7 @@ static struct io_plan *handle_peer_reestablish(struct io_conn *conn, struct htlc_map_iter it; const struct htlc *htlc; - if (gossip_msg(msg)) { + if (is_gossip_msg(msg)) { /* Forward to gossip daemon */ daemon_conn_send(&peer->gossip_client, msg); return peer_read_message(conn, &peer->pcs, diff --git a/lightningd/cryptomsg.c b/lightningd/cryptomsg.c index 532246c9a..1a3a4dde2 100644 --- a/lightningd/cryptomsg.c +++ b/lightningd/cryptomsg.c @@ -139,7 +139,7 @@ static struct io_plan *peer_decrypt_body(struct io_conn *conn, * A node MUST ignore a received message of unknown type, if that type * is odd. */ - if (unlikely(unknown_msg_discardable(decrypted))) { + if (unlikely(is_unknown_msg_discardable(decrypted))) { pcs->in = tal_free(pcs->in); return peer_read_message(conn, pcs, pcs->next_in); } diff --git a/lightningd/opening/opening.c b/lightningd/opening/opening.c index 491cc1a72..f652940cc 100644 --- a/lightningd/opening/opening.c +++ b/lightningd/opening/opening.c @@ -185,7 +185,7 @@ static u8 *read_next_peer_msg(struct state *state, const tal_t *ctx) peer_failed(PEER_FD, &state->cs, NULL, WIRE_OPENING_PEER_WRITE_FAILED, "Sending pong"); tal_free(pong); - } else if (gossip_msg(msg)) { + } else if (is_gossip_msg(msg)) { /* We relay gossip to gossipd, but don't relay from */ if (!wire_sync_write(GOSSIP_FD, take(msg))) peer_failed(PEER_FD, &state->cs, NULL, diff --git a/lightningd/test/run-cryptomsg.c b/lightningd/test/run-cryptomsg.c index f8a1ee0c7..83014f05f 100644 --- a/lightningd/test/run-cryptomsg.c +++ b/lightningd/test/run-cryptomsg.c @@ -50,7 +50,7 @@ char dev_disconnect(int pkt_type) } /* We test what look like unknown messages. */ -#define unknown_msg_discardable(x) 0 +#define is_unknown_msg_discardable(x) 0 #include "../cryptomsg.c" diff --git a/wire/peer_wire.c b/wire/peer_wire.c index e49791968..eb8d1a8df 100644 --- a/wire/peer_wire.c +++ b/wire/peer_wire.c @@ -31,7 +31,7 @@ static bool unknown_type(enum wire_type t) return true; } -bool gossip_msg(u8 *cursor) +bool is_gossip_msg(const u8 *cursor) { switch (fromwire_peektype(cursor)) { case WIRE_CHANNEL_ANNOUNCEMENT: @@ -62,13 +62,13 @@ bool gossip_msg(u8 *cursor) } /* Return true if it's an unknown message. cursor is a tal ptr. */ -bool unknown_msg(const u8 *cursor) +bool is_unknown_msg(const u8 *cursor) { return unknown_type(fromwire_peektype(cursor)); } /* Return true if it's an unknown ODD message. cursor is a tal ptr. */ -bool unknown_msg_discardable(const u8 *cursor) +bool is_unknown_msg_discardable(const u8 *cursor) { enum wire_type t = fromwire_peektype(cursor); return unknown_type(t) && (t & 1); diff --git a/wire/peer_wire.h b/wire/peer_wire.h index dbfdc0eeb..2c516f2e7 100644 --- a/wire/peer_wire.h +++ b/wire/peer_wire.h @@ -13,11 +13,11 @@ */ /* Return true if it's an unknown message. cursor is a tal ptr. */ -bool unknown_msg(const u8 *cursor); +bool is_unknown_msg(const u8 *cursor); /* Return true if it's an unknown ODD message. cursor is a tal ptr. */ -bool unknown_msg_discardable(const u8 *cursor); +bool is_unknown_msg_discardable(const u8 *cursor); /* Return true if it's a gossip message. */ -bool gossip_msg(u8 *cursor); +bool is_gossip_msg(const u8 *cursor); /* Compare two short_channel_ids and return true if they are the equal */ bool short_channel_id_eq(const struct short_channel_id *a,