| 1210 | } |
| 1211 | |
| 1212 | u32 feerate_max(struct lightningd *ld, bool *unknown) |
| 1213 | { |
| 1214 | const struct chain_topology *topo = ld->topology; |
| 1215 | u32 max = 0; |
| 1216 | u64 scaled; |
| 1217 | |
| 1218 | if (unknown) |
| 1219 | *unknown = false; |
| 1220 | |
| 1221 | for (size_t i = 0; i < ARRAY_SIZE(topo->feerates); i++) { |
| 1222 | const size_t num_feerates = tal_count(topo->feerates[i]); |
| 1223 | for (size_t j = 0; j < num_feerates; j++) { |
| 1224 | if (topo->feerates[i][j].rate > max) |
| 1225 | max = topo->feerates[i][j].rate; |
| 1226 | } |
| 1227 | } |
| 1228 | if (!max) { |
| 1229 | if (unknown) |
| 1230 | *unknown = true; |
| 1231 | /* No estimates: fall back to the ceiling, exactly as |
| 1232 | * feerate_min falls back to the floor. Returning UINT_MAX |
| 1233 | * here would be a sentinel meaning "no bound at all", and |
| 1234 | * that bound is what a peer's proposal gets measured |
| 1235 | * against and what we then store: a value that large |
| 1236 | * overflows the 25/24 RBF calculation. */ |
| 1237 | return FEERATE_CEILING; |
| 1238 | } |
| 1239 | /* Estimates are clamped to FEERATE_CEILING on the way in, but the |
| 1240 | * multiplier is settable, so widen before multiplying. */ |
| 1241 | scaled = (u64)max * topo->ld->config.max_fee_multiplier; |
| 1242 | |
| 1243 | /* Don't let the multiplier carry us past the sanity ceiling: above |
| 1244 | * that a peer is not congested, their fee source is broken. */ |
| 1245 | if (scaled > FEERATE_CEILING) |
| 1246 | return FEERATE_CEILING; |
| 1247 | return scaled; |
| 1248 | } |
| 1249 | |
| 1250 | u32 our_feerate_max(struct lightningd *ld, bool *unknown) |
| 1251 | { |
no outgoing calls
no test coverage detected