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