mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +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:
@@ -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);
|
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);
|
void notify_feerate_change(struct lightningd *ld);
|
||||||
|
|
||||||
#if DEVELOPER
|
#if DEVELOPER
|
||||||
|
|||||||
@@ -18,6 +18,47 @@
|
|||||||
#include <lightningd/subd.h>
|
#include <lightningd/subd.h>
|
||||||
#include <wire/wire_sync.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)
|
static void lockin_complete(struct channel *channel)
|
||||||
{
|
{
|
||||||
/* We set this once we're locked in. */
|
/* We set this once we're locked in. */
|
||||||
|
|||||||
@@ -1671,47 +1671,6 @@ void htlcs_notify_new_block(struct lightningd *ld, u32 height)
|
|||||||
} while (removed);
|
} 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
|
#if DEVELOPER
|
||||||
static void json_dev_ignore_htlcs(struct command *cmd, const char *buffer,
|
static void json_dev_ignore_htlcs(struct command *cmd, const char *buffer,
|
||||||
const jsmntok_t *params)
|
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 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 */
|
#endif /* LIGHTNING_LIGHTNINGD_PEER_HTLCS_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user