mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-22 08:34:20 +01:00
channeld: implement pending_updates()
Says if we have started an update which is still pending somewhere. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
neil saitug
parent
f7adbd5d58
commit
40e217872a
@@ -1252,6 +1252,34 @@ static bool adjust_balance(struct balance view_owed[NUM_SIDES][NUM_SIDES],
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool pending_updates(const struct channel *channel, enum side side)
|
||||||
|
{
|
||||||
|
struct htlc_map_iter it;
|
||||||
|
const struct htlc *htlc;
|
||||||
|
|
||||||
|
/* Initiator might have fee changes in play. */
|
||||||
|
if (side == channel->opener) {
|
||||||
|
if (!feerate_changes_done(channel->fee_states))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (htlc = htlc_map_first(channel->htlcs, &it);
|
||||||
|
htlc;
|
||||||
|
htlc = htlc_map_next(channel->htlcs, &it)) {
|
||||||
|
/* If it's still being added, it's owner added it. */
|
||||||
|
if (htlc_state_flags(htlc->state) & HTLC_ADDING) {
|
||||||
|
if (htlc_owner(htlc) == side)
|
||||||
|
return true;
|
||||||
|
/* If it's being removed, non-owner removed it */
|
||||||
|
} else if (htlc_state_flags(htlc->state) & HTLC_REMOVING) {
|
||||||
|
if (htlc_owner(htlc) != side)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool channel_force_htlcs(struct channel *channel,
|
bool channel_force_htlcs(struct channel *channel,
|
||||||
const struct existing_htlc **htlcs)
|
const struct existing_htlc **htlcs)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -254,6 +254,13 @@ bool channel_force_htlcs(struct channel *channel,
|
|||||||
*/
|
*/
|
||||||
void dump_htlcs(const struct channel *channel, const char *prefix);
|
void dump_htlcs(const struct channel *channel, const char *prefix);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pending_updates: does this side have updates pending in channel?
|
||||||
|
* @channel: the channel
|
||||||
|
* @side: the side who is offering or failing/fulfilling HTLC, or feechange
|
||||||
|
*/
|
||||||
|
bool pending_updates(const struct channel *channel, enum side side);
|
||||||
|
|
||||||
const char *channel_add_err_name(enum channel_add_err e);
|
const char *channel_add_err_name(enum channel_add_err e);
|
||||||
const char *channel_remove_err_name(enum channel_remove_err e);
|
const char *channel_remove_err_name(enum channel_remove_err e);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user