lightningd/payalgo.c
static void json_pay_sendpay_resolve(const struct sendpay_result *r,
				     void *vpay)
{
	struct pay *pay = (struct pay *) vpay;
	char const *why;

	/* If we succeed, hurray */
	if (r->succeeded) {
		log_info(pay->cmd->ld->log, "pay(%p): Success", pay);
		json_pay_success(pay->cmd, &r->preimage,
				 pay->getroute_tries, pay->sendpay_tries);
		return;
	}

	/* We can retry only if it is one of the retryable errors
	 * below. If it is not, fail now. */
	if (r->errorcode != PAY_UNPARSEABLE_ONION &&
	    r->errorcode != PAY_TRY_OTHER_ROUTE) {
		log_info(pay->cmd->ld->log, "pay(%p): Failed, reporting to caller", pay);
		json_pay_failure(pay, r);
		return;
	}

	/* Should retry here, question is whether to retry now or later */

	why = should_delay_retry(pay->try_parent, r);
	if (why) {
		log_info(pay->cmd->ld->log,
			 "pay(%p): Delay before retry: %s", pay, why);
		/* Delay for 3 seconds if needed. FIXME: random
		 * exponential backoff */
		new_reltimer(&pay->cmd->ld->timers, pay->try_parent,
			     time_from_sec(3),
			     &do_pay_try, pay);
	} else
		do_pay_try(pay);
}
/* Call when sendpay returns to us. */
Call when sendpay returns to us.
Call when sendpay returns to us .
static void json_pay_sendpay_resolve(const struct sendpay_result *r,
				     void *vpay)
{
	struct pay *pay = (struct pay *) vpay;
	char const *why;
	if (r->succeeded) {
		log_info(pay->cmd->ld->log, "pay(%p): Success", pay);
		json_pay_success(pay->cmd, &r->preimage,
				 pay->getroute_tries, pay->sendpay_tries);
		return;
	}
	if (r->errorcode != PAY_UNPARSEABLE_ONION &&
	    r->errorcode != PAY_TRY_OTHER_ROUTE) {
		log_info(pay->cmd->ld->log, "pay(%p): Failed, reporting to caller", pay);
		json_pay_failure(pay, r);
		return;
	}
	why = should_delay_retry(pay->try_parent, r);
	if (why) {
		log_info(pay->cmd->ld->log,
			 "pay(%p): Delay before retry: %s", pay, why);
		new_reltimer(&pay->cmd->ld->timers, pay->try_parent,
			     time_from_sec(3),
			     &do_pay_try, pay);
	} else
		do_pay_try(pay);
}
static void json_pay_sendpay_resolve ( const struct sendpay_result * r , void * vpay ) { struct pay * pay = ( struct pay * ) vpay ; char const * why ; if ( r -> succeeded ) { log_info ( pay -> cmd -> ld -> log , " " , pay ) ; json_pay_success ( pay -> cmd , & r -> preimage , pay -> getroute_tries , pay -> sendpay_tries ) ; return ; } if ( r -> errorcode != PAY_UNPARSEABLE_ONION && r -> errorcode != PAY_TRY_OTHER_ROUTE ) { log_info ( pay -> cmd -> ld -> log , " " , pay ) ; json_pay_failure ( pay , r ) ; return ; } why = should_delay_retry ( pay -> try_parent , r ) ; if ( why ) { log_info ( pay -> cmd -> ld -> log , " " , pay , why ) ; new_reltimer ( & pay -> cmd -> ld -> timers , pay -> try_parent , time_from_sec ( 3 ) , & do_pay_try , pay ) ; } else do_pay_try ( pay ) ; }
Call when sendpay returns to us.
Call when sendpay returns to us .
/* If we succeed, hurray */ /* We can retry only if it is one of the retryable errors
	 * below. If it is not, fail now. */ /* Should retry here, question is whether to retry now or later */ /* Delay for 3 seconds if needed. FIXME: random
		 * exponential backoff */