channel: move inflight + feerate methods to channel.c

Need these more accessible for next patch, which moves the next_feerate
info into listpeers
This commit is contained in:
niftynei 2021-02-19 12:44:36 -06:00 committed by Rusty Russell
parent a23277af57
commit 6c76dd338e
3 changed files with 30 additions and 15 deletions

View File

@ -715,6 +715,29 @@ void channel_fail_forget(struct channel *channel, const char *fmt, ...)
tal_free(why);
}
struct channel_inflight *
channel_current_inflight(const struct channel *channel)
{
struct channel_inflight *inflight;
/* The last inflight should always be the one in progress */
inflight = list_tail(&channel->inflights,
struct channel_inflight,
list);
if (inflight)
assert(bitcoin_txid_eq(&channel->funding_txid,
&inflight->funding->txid));
return inflight;
}
u32 channel_last_funding_feerate(const struct channel *channel)
{
struct channel_inflight *inflight;
inflight = channel_current_inflight(channel);
if (!inflight)
return 0;
return inflight->funding->feerate;
}
void channel_internal_error(struct channel *channel, const char *fmt, ...)
{
va_list ap;

View File

@ -286,6 +286,13 @@ new_inflight(struct channel *channel,
struct channel_inflight *channel_inflight_find(struct channel *channel,
const struct bitcoin_txid *txid);
/* What's the most recent inflight for this channel? */
struct channel_inflight *
channel_current_inflight(const struct channel *channel);
/* What's the last feerate used for a funding tx on this channel? */
u32 channel_last_funding_feerate(const struct channel *channel);
void delete_channel(struct channel *channel STEALS);
const char *channel_state_name(const struct channel *channel);

View File

@ -119,21 +119,6 @@ void json_add_unsaved_channel(struct json_stream *response,
json_object_end(response);
}
static struct channel_inflight *
channel_current_inflight(struct channel *channel)
{
struct channel_inflight *inflight;
/* The last inflight should always be the one in progress */
inflight = list_tail(&channel->inflights,
struct channel_inflight,
list);
if (inflight)
assert(bitcoin_txid_eq(&channel->funding_txid,
&inflight->funding->txid));
return inflight;
}
static void handle_signed_psbt(struct lightningd *ld,
struct subd *dualopend,
const struct wally_psbt *psbt,