mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 01:43:36 +01:00
moveonly: move feerate routines from peer_htlcs.c to channel_control.c
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
607d4bf9d2
commit
807e62b05d
@ -155,6 +155,7 @@ void begin_topology(struct chain_topology *topo);
|
||||
|
||||
struct txlocator *locate_tx(const void *ctx, const struct chain_topology *topo, const struct bitcoin_txid *txid);
|
||||
|
||||
/* In channel_control.c */
|
||||
void notify_feerate_change(struct lightningd *ld);
|
||||
|
||||
#if DEVELOPER
|
||||
|
@ -18,6 +18,47 @@
|
||||
#include <lightningd/subd.h>
|
||||
#include <wire/wire_sync.h>
|
||||
|
||||
static void update_feerates(struct lightningd *ld, struct channel *channel)
|
||||
{
|
||||
u8 *msg = towire_channel_feerates(NULL,
|
||||
get_feerate(ld->topology,
|
||||
FEERATE_IMMEDIATE),
|
||||
feerate_min(ld),
|
||||
feerate_max(ld));
|
||||
subd_send_msg(channel->owner, take(msg));
|
||||
}
|
||||
|
||||
static void try_update_feerates(struct lightningd *ld, struct channel *channel)
|
||||
{
|
||||
/* No point until funding locked in */
|
||||
if (!channel_fees_can_change(channel))
|
||||
return;
|
||||
|
||||
/* Can't if no daemon listening. */
|
||||
if (!channel->owner)
|
||||
return;
|
||||
|
||||
update_feerates(ld, channel);
|
||||
}
|
||||
|
||||
void notify_feerate_change(struct lightningd *ld)
|
||||
{
|
||||
struct peer *peer;
|
||||
|
||||
/* FIXME: We should notify onchaind about NORMAL fee change in case
|
||||
* it's going to generate more txs. */
|
||||
list_for_each(&ld->peers, peer, list) {
|
||||
struct channel *channel = peer_active_channel(peer);
|
||||
|
||||
if (!channel)
|
||||
continue;
|
||||
|
||||
/* FIXME: We choose not to drop to chain if we can't contact
|
||||
* peer. We *could* do so, however. */
|
||||
try_update_feerates(ld, channel);
|
||||
}
|
||||
}
|
||||
|
||||
static void lockin_complete(struct channel *channel)
|
||||
{
|
||||
/* We set this once we're locked in. */
|
||||
|
@ -1671,47 +1671,6 @@ void htlcs_notify_new_block(struct lightningd *ld, u32 height)
|
||||
} while (removed);
|
||||
}
|
||||
|
||||
static void update_feerates(struct lightningd *ld, struct channel *channel)
|
||||
{
|
||||
u8 *msg = towire_channel_feerates(NULL,
|
||||
get_feerate(ld->topology,
|
||||
FEERATE_IMMEDIATE),
|
||||
feerate_min(ld),
|
||||
feerate_max(ld));
|
||||
subd_send_msg(channel->owner, take(msg));
|
||||
}
|
||||
|
||||
void try_update_feerates(struct lightningd *ld, struct channel *channel)
|
||||
{
|
||||
/* No point until funding locked in */
|
||||
if (!channel_fees_can_change(channel))
|
||||
return;
|
||||
|
||||
/* Can't if no daemon listening. */
|
||||
if (!channel->owner)
|
||||
return;
|
||||
|
||||
update_feerates(ld, channel);
|
||||
}
|
||||
|
||||
void notify_feerate_change(struct lightningd *ld)
|
||||
{
|
||||
struct peer *peer;
|
||||
|
||||
/* FIXME: We should notify onchaind about NORMAL fee change in case
|
||||
* it's going to generate more txs. */
|
||||
list_for_each(&ld->peers, peer, list) {
|
||||
struct channel *channel = peer_active_channel(peer);
|
||||
|
||||
if (!channel)
|
||||
continue;
|
||||
|
||||
/* FIXME: We choose not to drop to chain if we can't contact
|
||||
* peer. We *could* do so, however. */
|
||||
try_update_feerates(ld, channel);
|
||||
}
|
||||
}
|
||||
|
||||
#if DEVELOPER
|
||||
static void json_dev_ignore_htlcs(struct command *cmd, const char *buffer,
|
||||
const jsmntok_t *params)
|
||||
|
@ -60,5 +60,4 @@ void onchain_fulfilled_htlc(struct channel *channel,
|
||||
|
||||
void htlcs_notify_new_block(struct lightningd *ld, u32 height);
|
||||
|
||||
void try_update_feerates(struct lightningd *ld, struct channel *channel);
|
||||
#endif /* LIGHTNING_LIGHTNINGD_PEER_HTLCS_H */
|
||||
|
Loading…
Reference in New Issue
Block a user