The calculation starts with a 100% margin at very low fees, since * they are likely to rise, and can do so quickly, whereas on the * higher fee side, asking for a 100% margin is excessive, so ask for * a 10% margin. In-between these two regions we interpolate * linearly. Notice that minfeerate and maxfeerate are just the * markers of the linear interpolation, they don't have to correspond *
| 164 | * markers of the linear interpolation, they don't have to correspond |
| 165 | * to actual feerates seen in the network. */ |
| 166 | u32 marginal_feerate(u32 current_feerate) |
| 167 | { |
| 168 | const u32 minfeerate = 253, maxfeerate = 45000; |
| 169 | |
| 170 | #ifdef TEST_ALLOW_ZERO_FEERATE |
| 171 | /* The BOLT test for commitment transactions does this. */ |
| 172 | if (current_feerate == 0) |
| 173 | return 0; |
| 174 | #endif |
| 175 | /* This could happen in future if we celebrate sub-sat summer! */ |
| 176 | if (current_feerate < minfeerate) |
| 177 | current_feerate = minfeerate; |
| 178 | if (current_feerate > maxfeerate) |
| 179 | return current_feerate * 1.1; |
| 180 | |
| 181 | /* min gives 1, max gives 0.1 */ |
| 182 | double proportion = 1.0 - ((double)current_feerate - minfeerate) / (maxfeerate - minfeerate) * 0.9; |
| 183 | |
| 184 | return current_feerate + proportion * current_feerate; |
| 185 | } |
| 186 | |
| 187 | char *fmt_fee_states(const tal_t *ctx, |
| 188 | const struct fee_states *fee_states) |
no outgoing calls