Skip to content

Commit

Permalink
wireaddr: moves wireaddr_arr_contains to wireaddr.h
Browse files Browse the repository at this point in the history
...So it can be reused somewhere else

Changelog-None
  • Loading branch information
m-schmoock authored and rustyrussell committed Jun 17, 2022
1 parent de9bc17 commit 55cf413
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
9 changes: 9 additions & 0 deletions common/wireaddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -899,3 +899,12 @@ int wireaddr_cmp_type(const struct wireaddr *a,
return tal_bytelen(a_wire) - tal_bytelen(b_wire);
return cmp;
}

bool wireaddr_arr_contains(const struct wireaddr *was,
const struct wireaddr *wa)
{
for (size_t i = 0; i < tal_count(was); i++)
if (wireaddr_eq(&was[i], wa))
return true;
return false;
}
3 changes: 3 additions & 0 deletions common/wireaddr.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,7 @@ struct wireaddr *fromwire_wireaddr_array(const tal_t *ctx, const u8 *ser);
int wireaddr_cmp_type(const struct wireaddr *a,
const struct wireaddr *b, void *unused);

bool wireaddr_arr_contains(const struct wireaddr *was,
const struct wireaddr *wa);

#endif /* LIGHTNING_COMMON_WIREADDR_H */
9 changes: 0 additions & 9 deletions gossipd/gossip_generation.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@
#include <hsmd/hsmd_wiregen.h>
#include <wire/wire_sync.h>

static bool wireaddr_arr_contains(const struct wireaddr *was,
const struct wireaddr *wa)
{
for (size_t i = 0; i < tal_count(was); i++)
if (wireaddr_eq(&was[i], wa))
return true;
return false;
}

/* Create a node_announcement with the given signature. It may be NULL in the
* case we need to create a provisional announcement for the HSM to sign.
* This is called twice: once with the dummy signature to get it signed and a
Expand Down

0 comments on commit 55cf413

Please sign in to comment.