mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 01:24:26 +01:00
gossipd: local_direction helper to generalize is_local_channel.
Increasingly we want to know is it local, and get the direction: it's more efficient to do both at once. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -273,6 +273,21 @@ struct routing_state {
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Which direction are we? False if neither. */
|
||||
static inline bool local_direction(struct routing_state *rstate,
|
||||
const struct chan *chan,
|
||||
int *direction)
|
||||
{
|
||||
for (int dir = 0; dir <= 1; (dir)++) {
|
||||
if (node_id_eq(&chan->nodes[dir]->id, &rstate->local_id)) {
|
||||
if (direction)
|
||||
*direction = dir;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline struct chan *
|
||||
get_channel(const struct routing_state *rstate,
|
||||
const struct short_channel_id *scid)
|
||||
|
||||
Reference in New Issue
Block a user