Browse Source

moveonly: move feerate routines from peer_htlcs.c to channel_control.c

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
807e62b05d
  1. 1
      lightningd/chaintopology.h
  2. 41
      lightningd/channel_control.c
  3. 41
      lightningd/peer_htlcs.c
  4. 1
      lightningd/peer_htlcs.h

1
lightningd/chaintopology.h

@ -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

41
lightningd/channel_control.c

@ -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. */

41
lightningd/peer_htlcs.c

@ -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)

1
lightningd/peer_htlcs.h

@ -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…
Cancel
Save