diff --git a/common/wireaddr.c b/common/wireaddr.c index 1ff8ca132..48542eb78 100644 --- a/common/wireaddr.c +++ b/common/wireaddr.c @@ -17,6 +17,15 @@ #include #include +bool wireaddr_eq(const struct wireaddr *a, const struct wireaddr *b) +{ + if (a->type != b->type) + return false; + if (a->port != b->port) + return false; + return memeq(a->addr, a->addrlen, b->addr, b->addrlen); +} + /* Returns false if we didn't parse it, and *cursor == NULL if malformed. */ bool fromwire_wireaddr(const u8 **cursor, size_t *max, struct wireaddr *addr) { diff --git a/common/wireaddr.h b/common/wireaddr.h index f8c1d0720..70e9723f0 100644 --- a/common/wireaddr.h +++ b/common/wireaddr.h @@ -61,6 +61,8 @@ struct wireaddr { u16 port; }; +bool wireaddr_eq(const struct wireaddr *a, const struct wireaddr *b); + /* We use wireaddr to tell gossipd both what to listen on, and what to * announce */ enum addr_listen_announce {