gossip: Added short_channel_id_to_uint for uintmap index

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker 2018-01-30 20:11:27 +01:00 committed by Rusty Russell
parent 0bc2f8714d
commit d7224e2178
2 changed files with 9 additions and 0 deletions

View File

@ -32,3 +32,9 @@ bool short_channel_id_eq(const struct short_channel_id *a,
return a->blocknum == b->blocknum && a->txnum == b->txnum &&
a->outnum == b->outnum;
}
u64 short_channel_id_to_uint(const struct short_channel_id *scid)
{
return ((u64)scid->blocknum & 0xFFFFFF) << 40 |
((u64)scid->txnum & 0xFFFFFF) << 16 | (scid->outnum & 0xFFFF);
}

View File

@ -25,4 +25,7 @@ bool short_channel_id_eq(const struct short_channel_id *a,
char *short_channel_id_to_str(const tal_t *ctx, const struct short_channel_id *scid);
/* Fast, platform dependent, way to convert from a short_channel_id to u64 */
u64 short_channel_id_to_uint(const struct short_channel_id *scid);
#endif /* LIGHTNING_BITCOIN_SHORT_CHANNEL_ID_H */