diff --git a/lightningd/chaintopology.c b/lightningd/chaintopology.c index d9d27f239..9d07de42c 100644 --- a/lightningd/chaintopology.c +++ b/lightningd/chaintopology.c @@ -303,10 +303,14 @@ static void update_feerates(struct bitcoind *bitcoind, const u32 *satoshi_per_kw, struct chain_topology *topo) { + u32 old_feerates[NUM_FEERATES]; + bool changed = false; + for (size_t i = 0; i < NUM_FEERATES; i++) { log_debug(topo->log, "%s feerate %u (was %u)", feerate_name(i), satoshi_per_kw[i], topo->feerate[i]); + old_feerates[i] = topo->feerate[i]; topo->feerate[i] = satoshi_per_kw[i]; } @@ -320,7 +324,12 @@ static void update_feerates(struct bitcoind *bitcoind, topo->feerate[j] = topo->feerate[i]; } } + if (topo->feerate[i] != old_feerates[i]) + changed = true; } + + if (changed) + notify_feerate_change(bitcoind->ld); } /* B is the new chain (linked by ->next); update topology */ diff --git a/lightningd/chaintopology.h b/lightningd/chaintopology.h index 9ae34f88d..aceece3ef 100644 --- a/lightningd/chaintopology.h +++ b/lightningd/chaintopology.h @@ -164,6 +164,7 @@ void setup_topology(struct chain_topology *topology, struct txlocator *locate_tx(const void *ctx, const struct chain_topology *topo, const struct sha256_double *txid); void notify_new_block(struct lightningd *ld, unsigned int height); +void notify_feerate_change(struct lightningd *ld); #if DEVELOPER void json_dev_broadcast(struct command *cmd, diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index 723d47973..164855286 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -1522,3 +1522,8 @@ void notify_new_block(struct lightningd *ld, u32 height) /* Iteration while removing is safe, but can skip entries! */ } while (removed); } + +void notify_feerate_change(struct lightningd *ld) +{ + /* FIXME: Do something! */ +}