From c5d41a23d776dfb02aa396aae39a61a03e080aee Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 1 Mar 2018 19:53:16 +1030 Subject: [PATCH] short_channel_id: just use structeq. Signed-off-by: Rusty Russell --- bitcoin/short_channel_id.h | 6 ------ channeld/channel.c | 4 ++-- gossipd/gossip.c | 6 ++---- gossipd/routing.c | 2 +- lightningd/peer_control.c | 2 +- wallet/test/run-wallet.c | 2 +- wire/test/run-peer-wire.c | 6 +++--- 7 files changed, 10 insertions(+), 18 deletions(-) diff --git a/bitcoin/short_channel_id.h b/bitcoin/short_channel_id.h index e3278095b..1aa533e3a 100644 --- a/bitcoin/short_channel_id.h +++ b/bitcoin/short_channel_id.h @@ -36,12 +36,6 @@ void mk_short_channel_id(struct short_channel_id *scid, bool short_channel_id_from_str(const char *str, size_t strlen, struct short_channel_id *dst); -static inline bool short_channel_id_eq(const struct short_channel_id *a, - const struct short_channel_id *b) -{ - return a->u64 == b->u64; -} - /* Fast, platform dependent, way to convert from a short_channel_id to u64 */ static inline u64 short_channel_id_to_uint(const struct short_channel_id *scid) { diff --git a/channeld/channel.c b/channeld/channel.c index 3caab5659..ebe28241f 100644 --- a/channeld/channel.c +++ b/channeld/channel.c @@ -533,8 +533,8 @@ static void check_short_ids_match(struct peer *peer) assert(peer->have_sigs[LOCAL]); assert(peer->have_sigs[REMOTE]); - if (!short_channel_id_eq(&peer->short_channel_ids[LOCAL], - &peer->short_channel_ids[REMOTE])) + if (!structeq(&peer->short_channel_ids[LOCAL], + &peer->short_channel_ids[REMOTE])) peer_failed(&peer->cs, peer->gossip_index, &peer->channel_id, "We disagree on short_channel_ids:" diff --git a/gossipd/gossip.c b/gossipd/gossip.c index 2429bc8a5..e92a85529 100644 --- a/gossipd/gossip.c +++ b/gossipd/gossip.c @@ -733,8 +733,7 @@ static void handle_get_update(struct peer *peer, const u8 *msg) } for (i = 0; i < tal_count(us->out); i++) { - if (!short_channel_id_eq(&us->out[i]->short_channel_id, - &schanid)) + if (!structeq(&us->out[i]->short_channel_id, &schanid)) continue; update = us->out[i]->channel_update; @@ -1093,8 +1092,7 @@ static struct io_plan *getchannels_req(struct io_conn *conn, struct daemon *daem while (n != NULL) { for (j=0; jout); j++){ if (scid && - !short_channel_id_eq(scid, - &n->out[j]->short_channel_id)) { + !structeq(scid, &n->out[j]->short_channel_id)) { continue; } tal_resize(&entries, num_chans + 1); diff --git a/gossipd/routing.c b/gossipd/routing.c index b22689fb8..c0692f2c0 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -1194,7 +1194,7 @@ get_out_node_connection_of(const struct node *node, int i; for (i = 0; i < tal_count(node->out); ++i) { - if (short_channel_id_eq(&node->out[i]->short_channel_id, short_channel_id)) + if (structeq(&node->out[i]->short_channel_id, short_channel_id)) return node->out[i]; } diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 5e5666242..4ef62c26e 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -1069,7 +1069,7 @@ static void json_dev_forget_channel(struct command *cmd, const char *buffer, if (scidtok) { if (!channel->scid) continue; - if (!short_channel_id_eq(channel->scid, &scid)) + if (!structeq(channel->scid, &scid)) continue; } if (forget->channel) { diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index a828fed32..d0cc2f4d7 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -610,7 +610,7 @@ static bool channelseq(struct channel *c1, struct channel *c2) CHECK(c1->peer == c2->peer); CHECK(c1->their_shachain.id == c2->their_shachain.id); CHECK_MSG(pubkey_eq(&p1->id, &p2->id), "NodeIDs do not match"); - CHECK((c1->scid == NULL && c2->scid == NULL) || short_channel_id_eq(c1->scid, c2->scid)); + CHECK((c1->scid == NULL && c2->scid == NULL) || structeq(c1->scid, c2->scid)); CHECK(c1->our_msatoshi == c2->our_msatoshi); CHECK((c1->remote_shutdown_scriptpubkey == NULL && c2->remote_shutdown_scriptpubkey == NULL) || memeq( c1->remote_shutdown_scriptpubkey, diff --git a/wire/test/run-peer-wire.c b/wire/test/run-peer-wire.c index 3ed3531bc..422d27670 100644 --- a/wire/test/run-peer-wire.c +++ b/wire/test/run-peer-wire.c @@ -704,7 +704,7 @@ static bool channel_announcement_eq(const struct msg_channel_announcement *a, return eq_upto(a, b, features) && eq_var(a, b, features) && eq_field(a, b, chain_hash) - && short_channel_id_eq(&a->short_channel_id, &b->short_channel_id) + && structeq(&a->short_channel_id, &b->short_channel_id) && eq_between(a, b, node_id_1, bitcoin_key_2); } @@ -718,7 +718,7 @@ static bool announcement_signatures_eq(const struct msg_announcement_signatures const struct msg_announcement_signatures *b) { return eq_upto(a, b, short_channel_id) && - short_channel_id_eq(&a->short_channel_id, &b->short_channel_id); + structeq(&a->short_channel_id, &b->short_channel_id); } static bool update_fail_htlc_eq(const struct msg_update_fail_htlc *a, @@ -804,7 +804,7 @@ static bool channel_update_eq(const struct msg_channel_update *a, const struct msg_channel_update *b) { return eq_upto(a, b, short_channel_id) && - short_channel_id_eq(&a->short_channel_id, &b->short_channel_id); + structeq(&a->short_channel_id, &b->short_channel_id); } static bool accept_channel_eq(const struct msg_accept_channel *a,