Skip to content

Commit 3424f70

Browse files
plugin: autoclean: cleanup the forwards with localfailed
While we are cleaning up the list forwards with the autoclean plugin we are not taking into count the forward's payments with the status set to `local_failed`. In this case, the forwards have no resolved time because it was not resolved by us due to some local error. So, this commit is fixing the auto clean plugin by allowing to delete of the forwards with status set to local_failed by taking into count the received_time, with the assumption that the received_time, in this case, is equal to the resolved time (?) Reported-by: @denis2342 Link: ElementsProject#6058 Signed-off-by: Vincenzo Palazzo <[email protected]> Changelog-Fixed: plugin: autoclean: considerer the forwards with status set to `local_failed`.
1 parent aa1a0e3 commit 3424f70

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

plugins/autoclean.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ static struct command_result *listforwards_done(struct command *cmd,
301301

302302
json_for_each_arr(i, t, fwds) {
303303
const jsmntok_t *status = json_get_member(buf, t, "status");
304+
const char *timefield = "resolved_time";
304305
jsmntok_t time;
305306
enum subsystem subsys;
306307
u64 restime;
@@ -310,6 +311,8 @@ static struct command_result *listforwards_done(struct command *cmd,
310311
} else if (json_tok_streq(buf, status, "failed")
311312
|| json_tok_streq(buf, status, "local_failed")) {
312313
subsys = FAILEDFORWARDS;
314+
/* There's no resolved_time for these, so use received */
315+
timefield = "received_time";
313316
} else {
314317
cinfo->num_uncleaned++;
315318
continue;
@@ -324,12 +327,13 @@ static struct command_result *listforwards_done(struct command *cmd,
324327
/* Check if we have a resolved_time, before making a
325328
* decision on it. This is possible in older nodes
326329
* that predate our annotations for forwards.*/
327-
if (json_get_member(buf, t, "resolved_time") == NULL) {
330+
if (json_get_member(buf, t, timefield) == NULL) {
328331
cinfo->num_uncleaned++;
329332
continue;
330333
}
331334

332-
time = *json_get_member(buf, t, "resolved_time");
335+
336+
time = *json_get_member(buf, t, timefield);
333337
/* This is a float, so truncate at '.' */
334338
for (int off = time.start; off < time.end; off++) {
335339
if (buf[off] == '.')

0 commit comments

Comments
 (0)