mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
common: add gossmap_chan_is_dying() helper to check flags.
And fix up gossip_store backwards comment! Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
27ef4b98c1
commit
5135658805
@ -44,8 +44,8 @@ struct gossip_rcvd_filter;
|
|||||||
* gossip_hdr -- On-disk format header.
|
* gossip_hdr -- On-disk format header.
|
||||||
*/
|
*/
|
||||||
struct gossip_hdr {
|
struct gossip_hdr {
|
||||||
beint16_t flags; /* Length of message after header. */
|
beint16_t flags; /* GOSSIP_STORE_xxx_BIT flags. */
|
||||||
beint16_t len; /* GOSSIP_STORE_xxx_BIT flags. */
|
beint16_t len; /* Length of message after header. */
|
||||||
beint32_t crc; /* crc of message of timestamp, after header. */
|
beint32_t crc; /* crc of message of timestamp, after header. */
|
||||||
beint32_t timestamp; /* timestamp of msg. */
|
beint32_t timestamp; /* timestamp of msg. */
|
||||||
};
|
};
|
||||||
|
@ -1093,6 +1093,19 @@ bool gossmap_chan_is_localmod(const struct gossmap *map,
|
|||||||
return c->cann_off >= map->map_size;
|
return c->cann_off >= map->map_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool gossmap_chan_is_dying(const struct gossmap *map,
|
||||||
|
const struct gossmap_chan *c)
|
||||||
|
{
|
||||||
|
struct gossip_hdr ghdr;
|
||||||
|
size_t off;
|
||||||
|
|
||||||
|
/* FIXME: put this flag in plus_scid_off instead? */
|
||||||
|
off = c->cann_off - sizeof(ghdr);
|
||||||
|
map_copy(map, off, &ghdr, sizeof(ghdr));
|
||||||
|
|
||||||
|
return ghdr.flags & CPU_TO_BE16(GOSSIP_STORE_DYING_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
bool gossmap_chan_get_capacity(const struct gossmap *map,
|
bool gossmap_chan_get_capacity(const struct gossmap *map,
|
||||||
const struct gossmap_chan *c,
|
const struct gossmap_chan *c,
|
||||||
struct amount_sat *amount)
|
struct amount_sat *amount)
|
||||||
|
@ -122,6 +122,10 @@ void gossmap_remove_localmods(struct gossmap *map,
|
|||||||
bool gossmap_chan_is_localmod(const struct gossmap *map,
|
bool gossmap_chan_is_localmod(const struct gossmap *map,
|
||||||
const struct gossmap_chan *c);
|
const struct gossmap_chan *c);
|
||||||
|
|
||||||
|
/* Is this channel dying? */
|
||||||
|
bool gossmap_chan_is_dying(const struct gossmap *map,
|
||||||
|
const struct gossmap_chan *c);
|
||||||
|
|
||||||
/* Each channel has a unique (low) index. */
|
/* Each channel has a unique (low) index. */
|
||||||
u32 gossmap_node_idx(const struct gossmap *map, const struct gossmap_node *node);
|
u32 gossmap_node_idx(const struct gossmap *map, const struct gossmap_node *node);
|
||||||
u32 gossmap_chan_idx(const struct gossmap *map, const struct gossmap_chan *chan);
|
u32 gossmap_chan_idx(const struct gossmap *map, const struct gossmap_chan *chan);
|
||||||
|
Loading…
Reference in New Issue
Block a user