@@ -1020,6 +1020,27 @@ static struct command_result *checktimeout_cb(struct payment *payment)
10201020
10211021REGISTER_PAYMENT_MODIFIER (checktimeout , checktimeout_cb );
10221022
1023+ /*****************************************************************************
1024+ * knowledgerelax
1025+ *
1026+ * Reduce the knowledge of the network as time goes by.
1027+ */
1028+
1029+ static struct command_result * knowledgerelax_cb (struct payment * payment )
1030+ {
1031+ const u64 now_sec = time_now ().ts .tv_sec ;
1032+ enum renepay_errorcode err = uncertainty_relax (
1033+ pay_plugin -> uncertainty , now_sec - pay_plugin -> last_time );
1034+ if (err )
1035+ plugin_err (pay_plugin -> plugin ,
1036+ "uncertainty_relax failed with error %s" ,
1037+ renepay_errorcode_name (err ));
1038+ pay_plugin -> last_time = now_sec ;
1039+ return payment_continue (payment );
1040+ }
1041+
1042+ REGISTER_PAYMENT_MODIFIER (knowledgerelax , knowledgerelax_cb );
1043+
10231044/*****************************************************************************
10241045 * alwaystrue
10251046 *
@@ -1068,29 +1089,29 @@ REGISTER_PAYMENT_CONDITION(retry, retry_cb);
10681089 */
10691090// TODO
10701091// add shadow route
1071- // add knowledge decay
10721092// add check pre-approved invoice
10731093void * payment_virtual_program [] = {
10741094 /*0*/ OP_CALL , & previous_sendpays_pay_mod ,
10751095 /*2*/ OP_CALL , & selfpay_pay_mod ,
1076- /*4*/ OP_CALL , & getmychannels_pay_mod ,
1077- /*6*/ OP_CALL , & routehints_pay_mod ,
1096+ /*4*/ OP_CALL , & knowledgerelax_pay_mod ,
1097+ /*6*/ OP_CALL , & getmychannels_pay_mod ,
1098+ /*8*/ OP_CALL , & routehints_pay_mod ,
10781099 // TODO: add a channel filter, for example disable channels that have
10791100 // htlcmax < 0.1% of payment amount, or base fee > 100msat, or
10801101 // proportional_fee > 10%, or capacity < 10% payment amount
10811102 // TODO shadow_additions
10821103 /* do */
1083- /*8 */ OP_CALL , & refreshgossmap_pay_mod ,
1084- /*10 */ OP_CALL , & checktimeout_pay_mod ,
1085- /*12 */ OP_CALL , & compute_routes_pay_mod ,
1086- /*14 */ OP_CALL , & send_routes_pay_mod ,
1104+ /*10 */ OP_CALL , & refreshgossmap_pay_mod ,
1105+ /*12 */ OP_CALL , & checktimeout_pay_mod ,
1106+ /*14 */ OP_CALL , & compute_routes_pay_mod ,
1107+ /*16 */ OP_CALL , & send_routes_pay_mod ,
10871108 /*do*/
1088- /*16 */ OP_CALL , & checktimeout_pay_mod ,
1089- /*18 */ OP_CALL , & sleep_pay_mod ,
1090- /*20 */ OP_CALL , & collect_results_pay_mod ,
1109+ /*18 */ OP_CALL , & checktimeout_pay_mod ,
1110+ /*20 */ OP_CALL , & sleep_pay_mod ,
1111+ /*22 */ OP_CALL , & collect_results_pay_mod ,
10911112 /*while*/
1092- /*22 */ OP_IF , & nothaveresults_pay_cond , (void * )16 ,
1113+ /*24 */ OP_IF , & nothaveresults_pay_cond , (void * )18 ,
10931114 /* while */
1094- /*25 */ OP_IF , & retry_pay_cond , (void * )8 ,
1095- /*28 */ OP_CALL , & end_pay_mod , /* safety net, default failure if reached */
1096- /*20 */ NULL };
1115+ /*27 */ OP_IF , & retry_pay_cond , (void * )10 ,
1116+ /*30 */ OP_CALL , & end_pay_mod , /* safety net, default failure if reached */
1117+ /*32 */ NULL };
0 commit comments