@@ -1509,6 +1509,36 @@ static struct command_result *getinfo_done(struct command *aux_cmd,
15091509 return aux_command_done (aux_cmd );
15101510}
15111511
1512+ /* Recursion */
1513+ static void start_aging_timer (struct plugin * plugin );
1514+
1515+ static struct command_result * age_done (struct command * timer_cmd ,
1516+ const char * method ,
1517+ const char * buf ,
1518+ const jsmntok_t * result ,
1519+ void * unused )
1520+ {
1521+ start_aging_timer (timer_cmd -> plugin );
1522+ return timer_complete (timer_cmd );
1523+ }
1524+
1525+ static struct command_result * age_layer (struct command * timer_cmd , void * unused )
1526+ {
1527+ struct out_req * req ;
1528+ req = jsonrpc_request_start (timer_cmd , "askrene-age" ,
1529+ age_done ,
1530+ plugin_broken_cb ,
1531+ NULL );
1532+ json_add_string (req -> js , "layer" , "xpay" );
1533+ json_add_u64 (req -> js , "cutoff" , time_now ().ts .tv_sec - 3600 );
1534+ return send_outreq (req );
1535+ }
1536+
1537+ static void start_aging_timer (struct plugin * plugin )
1538+ {
1539+ notleak (global_timer (plugin , time_from_sec (60 ), age_layer , NULL ));
1540+ }
1541+
15121542static const char * init (struct command * init_cmd ,
15131543 const char * buf UNUSED , const jsmntok_t * config UNUSED )
15141544{
@@ -1554,6 +1584,7 @@ static const char *init(struct command *init_cmd,
15541584 json_add_string (req -> js , "layer" , "xpay" );
15551585 send_outreq (req );
15561586
1587+ start_aging_timer (plugin );
15571588 return NULL ;
15581589}
15591590
0 commit comments