Browse Source

at startup initialize smoothed feerate to polled feerate

fix indentation
ppa-0.6.1
Simon Vrouwe 7 years ago
committed by Christian Decker
parent
commit
a80622edab
  1. 9
      lightningd/chaintopology.c

9
lightningd/chaintopology.c

@ -253,6 +253,11 @@ static void update_feerates(struct bitcoind *bitcoind,
if (!feerate) if (!feerate)
continue; continue;
/* Initial smoothed feerate is the polled feerate */
if (topo->startup) {
old_feerates[i] = feerate;
}
/* Smooth the feerate to avoid spikes. */ /* Smooth the feerate to avoid spikes. */
u32 feerate_smooth = feerate * alpha + old_feerates[i] * (1 - alpha); u32 feerate_smooth = feerate * alpha + old_feerates[i] * (1 - alpha);
/* But to avoid updating forever, only apply smoothing when its /* But to avoid updating forever, only apply smoothing when its
@ -278,6 +283,9 @@ static void update_feerates(struct bitcoind *bitcoind,
} }
topo->feerate[i] = feerate; topo->feerate[i] = feerate;
} }
/* Moving this forward in time is ok, but feerate smoothing is effectively
* disabled until topo->startup is set to false */
topo->startup = false;
/* Make sure fee rates are in order. */ /* Make sure fee rates are in order. */
for (size_t i = 0; i < NUM_FEERATES; i++) { for (size_t i = 0; i < NUM_FEERATES; i++) {
@ -685,6 +693,7 @@ struct chain_topology *new_topology(struct lightningd *ld, struct log *log)
topo->bitcoind = new_bitcoind(topo, ld, log); topo->bitcoind = new_bitcoind(topo, ld, log);
topo->wallet = ld->wallet; topo->wallet = ld->wallet;
topo->poll_seconds = 30; topo->poll_seconds = 30;
topo->startup = true;
#if DEVELOPER #if DEVELOPER
topo->dev_override_fee_rate = NULL; topo->dev_override_fee_rate = NULL;
#endif #endif

Loading…
Cancel
Save