bkpr: make sure there's always at least on difference in blockheights

We can't divide by zero, so make sure it's always 1 (with a small loss
of precision for other cases, ce la vie)
This commit is contained in:
niftynei
2022-07-19 17:04:39 +09:30
committed by Rusty Russell
parent 0c2b43b6b2
commit c1cef773ca
2 changed files with 12 additions and 2 deletions

View File

@@ -342,8 +342,8 @@ void json_add_channel_apy(struct json_stream *res,
tal_fmt(apy, "%.4f%%", utilization * 100));
}
blocks_elapsed = apy->end_blockheight - apy->start_blockheight;
assert(blocks_elapsed > 0);
/* Can't divide by zero */
blocks_elapsed = apy->end_blockheight - apy->start_blockheight + 1;
/* APY (outbound) */
ok = calc_apy(apy->fees_out, apy->total_start_bal,