MCPcopy Create free account
hub / github.com/ElementsProject/lightning / feerate_max

Function feerate_max

lightningd/chaintopology.c:1212–1248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1210}
1211
1212u32 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
1250u32 our_feerate_max(struct lightningd *ld, bool *unknown)
1251{

Callers 10

rbf_got_offerFunction · 0.85
accepter_got_offerFunction · 0.85
peer_start_dualopendFunction · 0.85
peer_restart_dualopendFunction · 0.85
json_feeratesFunction · 0.85
our_feerate_maxFunction · 0.85
peer_start_openingdFunction · 0.85
channel_update_feeratesFunction · 0.85
peer_start_channeldFunction · 0.85
json_dev_feerateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected