| 417 | } |
| 418 | |
| 419 | static struct per_variant *get_listforwards_variant(const char *buf, |
| 420 | const jsmntok_t *t, |
| 421 | struct per_subsystem *subsystem, |
| 422 | u64 *timestamp) |
| 423 | { |
| 424 | struct per_variant *variant; |
| 425 | const jsmntok_t *status = json_get_member(buf, t, "status"); |
| 426 | const char *timefield; |
| 427 | jsmntok_t time; |
| 428 | |
| 429 | if (json_tok_streq(buf, status, "settled")) { |
| 430 | timefield = "resolved_time"; |
| 431 | variant = &subsystem->variants[SUCCESS]; |
| 432 | } else if (json_tok_streq(buf, status, "failed") |
| 433 | || json_tok_streq(buf, status, "local_failed")) { |
| 434 | variant = &subsystem->variants[FAILURE]; |
| 435 | /* There's no resolved_time for these, so use received */ |
| 436 | timefield = "received_time"; |
| 437 | } else { |
| 438 | return NULL; |
| 439 | } |
| 440 | |
| 441 | /* Check if we have a resolved_time, before making a decision |
| 442 | * on it. This is possible in older nodes that predate our |
| 443 | * annotations for forwards.*/ |
| 444 | if (json_get_member(buf, t, timefield) == NULL) |
| 445 | return NULL; |
| 446 | |
| 447 | time = *json_get_member(buf, t, timefield); |
| 448 | /* This is a float, so truncate at '.' */ |
| 449 | for (int off = time.start; off < time.end; off++) { |
| 450 | if (buf[off] == '.') |
| 451 | time.end = off; |
| 452 | } |
| 453 | |
| 454 | if (!json_to_u64(buf, &time, timestamp)) { |
| 455 | plugin_err(plugin, "Bad listforwards time '%.*s'", |
| 456 | json_tok_full_len(&time), |
| 457 | json_tok_full(buf, &time)); |
| 458 | } |
| 459 | return variant; |
| 460 | } |
| 461 | |
| 462 | static struct per_variant *get_networkevent_variant(const char *buf, |
| 463 | const jsmntok_t *t, |
nothing calls this directly
no test coverage detected