| 2069 | } |
| 2070 | |
| 2071 | void payment_continue(struct payment *p) |
| 2072 | { |
| 2073 | struct payment_modifier *mod; |
| 2074 | void *moddata; |
| 2075 | /* If we are in the middle of calling the modifiers, continue calling |
| 2076 | * them, otherwise we can continue with the payment state-machine. */ |
| 2077 | p->current_modifier++; |
| 2078 | mod = p->modifiers[p->current_modifier]; |
| 2079 | |
| 2080 | if (mod != NULL) { |
| 2081 | /* There is another modifier, so call it. */ |
| 2082 | moddata = p->modifier_data[p->current_modifier]; |
| 2083 | return mod->post_step_cb(moddata, p); |
| 2084 | } else { |
| 2085 | /* There are no more modifiers, so reset the call chain and |
| 2086 | * proceed to the next state. */ |
| 2087 | p->current_modifier = -1; |
| 2088 | switch (p->step) { |
| 2089 | case PAYMENT_STEP_INITIALIZED: |
| 2090 | case PAYMENT_STEP_RETRY_GETROUTE: |
| 2091 | payment_getroute(p); |
| 2092 | return; |
| 2093 | |
| 2094 | case PAYMENT_STEP_GOT_ROUTE: |
| 2095 | payment_compute_onion_payloads(p); |
| 2096 | return; |
| 2097 | |
| 2098 | case PAYMENT_STEP_ONION_PAYLOAD: |
| 2099 | payment_sendonion(p); |
| 2100 | return; |
| 2101 | |
| 2102 | case PAYMENT_STEP_SUCCESS: |
| 2103 | case PAYMENT_STEP_FAILED: |
| 2104 | payment_finished(p); |
| 2105 | return; |
| 2106 | |
| 2107 | case PAYMENT_STEP_RETRY: |
| 2108 | case PAYMENT_STEP_SPLIT: |
| 2109 | /* Do nothing, we'll get pinged by a child succeeding |
| 2110 | * or failing. */ |
| 2111 | return; |
| 2112 | } |
| 2113 | } |
| 2114 | /* We should never get here, it'd mean one of the state machine called |
| 2115 | * `payment_continue` after the final state. */ |
| 2116 | abort(); |
| 2117 | } |
| 2118 | |
| 2119 | void payment_abort(struct payment *p, const char *fmt, ...) { |
| 2120 | va_list ap; |
no test coverage detected