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