| 182 | } |
| 183 | |
| 184 | static struct amount_sat |
| 185 | apply_policy(struct funder_policy *policy, |
| 186 | struct amount_sat their_funding, |
| 187 | struct amount_sat requested_lease, |
| 188 | struct amount_sat available_funds) |
| 189 | { |
| 190 | struct amount_sat our_funding; |
| 191 | |
| 192 | switch (policy->opt) { |
| 193 | case MATCH: |
| 194 | /* For matches, we use requested funding, if availalbe */ |
| 195 | if (!amount_sat_is_zero(requested_lease)) |
| 196 | their_funding = requested_lease; |
| 197 | |
| 198 | /* if this fails, it implies ludicrous funding offer, *and* |
| 199 | * > 100% match. Just Say No, kids. */ |
| 200 | if (!amount_sat_scale(&our_funding, their_funding, |
| 201 | policy->mod / 100.0)) |
| 202 | our_funding = AMOUNT_SAT(0); |
| 203 | return our_funding; |
| 204 | case AVAILABLE: |
| 205 | /* Use the 'available_funds' as the starting |
| 206 | * point for your contribution */ |
| 207 | if (!amount_sat_scale(&our_funding, available_funds, |
| 208 | policy->mod / 100.0)) |
| 209 | abort(); |
| 210 | return our_funding; |
| 211 | case FIXED: |
| 212 | /* Use a static amount */ |
| 213 | return amount_sat(policy->mod); |
| 214 | } |
| 215 | |
| 216 | abort(); |
| 217 | } |
| 218 | |
| 219 | const char * |
| 220 | calculate_our_funding(struct funder_policy *policy, |
no test coverage detected