mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-01 17:47:30 +01:00
lightningd/lightningd.h: Maintain a round-robin list of channels.
This commit is contained in:
parent
f50951a0d6
commit
a9a11265dd
5 changed files with 15 additions and 0 deletions
|
@ -110,6 +110,8 @@ static void destroy_channel(struct channel *channel)
|
||||||
channel_set_owner(channel, NULL);
|
channel_set_owner(channel, NULL);
|
||||||
|
|
||||||
list_del_from(&channel->peer->channels, &channel->list);
|
list_del_from(&channel->peer->channels, &channel->list);
|
||||||
|
|
||||||
|
list_del(&channel->rr_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void delete_channel(struct channel *channel STEALS)
|
void delete_channel(struct channel *channel STEALS)
|
||||||
|
@ -275,6 +277,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
|
||||||
channel->forgets = tal_arr(channel, struct command *, 0);
|
channel->forgets = tal_arr(channel, struct command *, 0);
|
||||||
|
|
||||||
list_add_tail(&peer->channels, &channel->list);
|
list_add_tail(&peer->channels, &channel->list);
|
||||||
|
list_add_tail(&peer->ld->rr_channels, &channel->rr_list);
|
||||||
tal_add_destructor(channel, destroy_channel);
|
tal_add_destructor(channel, destroy_channel);
|
||||||
|
|
||||||
/* Make sure we see any spends using this key */
|
/* Make sure we see any spends using this key */
|
||||||
|
|
|
@ -136,6 +136,9 @@ struct channel {
|
||||||
|
|
||||||
/* Any commands trying to forget us. */
|
/* Any commands trying to forget us. */
|
||||||
struct command **forgets;
|
struct command **forgets;
|
||||||
|
|
||||||
|
/* Our position in the round-robin list. */
|
||||||
|
struct list_node rr_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct channel *new_channel(struct peer *peer, u64 dbid,
|
struct channel *new_channel(struct peer *peer, u64 dbid,
|
||||||
|
|
|
@ -285,6 +285,11 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
|
||||||
*/
|
*/
|
||||||
ld->exit_code = NULL;
|
ld->exit_code = NULL;
|
||||||
|
|
||||||
|
/*~ We maintain a round-robin list of channels.
|
||||||
|
* This round-robin list of channels is used to ensure that
|
||||||
|
* each invoice we generate has a different set of channels. */
|
||||||
|
list_head_init(&ld->rr_channels);
|
||||||
|
|
||||||
return ld;
|
return ld;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -274,6 +274,9 @@ struct lightningd {
|
||||||
|
|
||||||
/* If non-NULL, contains the exit code to use. */
|
/* If non-NULL, contains the exit code to use. */
|
||||||
int *exit_code;
|
int *exit_code;
|
||||||
|
|
||||||
|
/* The round-robin list of channels, for use when doing MPP. */
|
||||||
|
struct list_head rr_channels;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Turning this on allows a tal allocation to return NULL, rather than aborting.
|
/* Turning this on allows a tal allocation to return NULL, rather than aborting.
|
||||||
|
|
|
@ -1498,6 +1498,7 @@ int main(int argc, const char *argv[])
|
||||||
|
|
||||||
/* Only elements in ld we should access */
|
/* Only elements in ld we should access */
|
||||||
list_head_init(&ld->peers);
|
list_head_init(&ld->peers);
|
||||||
|
list_head_init(&ld->rr_channels);
|
||||||
node_id_from_hexstr("02a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc", 66, &ld->id);
|
node_id_from_hexstr("02a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc", 66, &ld->id);
|
||||||
/* Accessed in peer destructor sanity check */
|
/* Accessed in peer destructor sanity check */
|
||||||
htlc_in_map_init(&ld->htlcs_in);
|
htlc_in_map_init(&ld->htlcs_in);
|
||||||
|
|
Loading…
Add table
Reference in a new issue