mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-17 19:03:42 +01:00
chaintopology: fix default feerate.
We never hit the guess_feerate() path, because we turned a 0 ("can't estimate fee") into 253. This also revealed that we weren't initializing topo->feerate, and that we were giving spurious updates even if we were using override-fee-rates. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
c8cc8fd83f
commit
ceb1ce0ef5
@ -280,6 +280,13 @@ static void update_feerates(struct bitcoind *bitcoind,
|
||||
for (size_t i = 0; i < NUM_FEERATES; i++) {
|
||||
u32 feerate = satoshi_per_kw[i];
|
||||
|
||||
/* Takes into account override_fee_rate */
|
||||
old_feerates[i] = get_feerate(topo, i);
|
||||
|
||||
/* If estimatefee failed, don't do anything. */
|
||||
if (!feerate)
|
||||
continue;
|
||||
|
||||
if (feerate < feerate_floor())
|
||||
feerate = feerate_floor();
|
||||
|
||||
@ -292,10 +299,10 @@ static void update_feerates(struct bitcoind *bitcoind,
|
||||
"...feerate %u hit floor %u",
|
||||
satoshi_per_kw[i], feerate);
|
||||
}
|
||||
old_feerates[i] = topo->feerate[i];
|
||||
topo->feerate[i] = feerate;
|
||||
}
|
||||
|
||||
/* Make sure fee rates are in order. */
|
||||
for (size_t i = 0; i < NUM_FEERATES; i++) {
|
||||
for (size_t j = 0; j < i; j++) {
|
||||
if (topo->feerate[j] < topo->feerate[i]) {
|
||||
@ -306,7 +313,7 @@ static void update_feerates(struct bitcoind *bitcoind,
|
||||
topo->feerate[j] = topo->feerate[i];
|
||||
}
|
||||
}
|
||||
if (topo->feerate[i] != old_feerates[i])
|
||||
if (get_feerate(topo, i) != old_feerates[i])
|
||||
changed = true;
|
||||
}
|
||||
|
||||
@ -719,6 +726,7 @@ struct chain_topology *new_topology(struct lightningd *ld, struct log *log)
|
||||
txowatch_hash_init(&topo->txowatches);
|
||||
topo->log = log;
|
||||
topo->default_fee_rate = 40000;
|
||||
memset(topo->feerate, 0, sizeof(topo->feerate));
|
||||
topo->override_fee_rate = NULL;
|
||||
topo->bitcoind = new_bitcoind(topo, ld, log);
|
||||
topo->wallet = ld->wallet;
|
||||
|
Loading…
Reference in New Issue
Block a user