MCPcopy Create free account
hub / github.com/ElementsProject/lightning / payment_is_finished

Function payment_is_finished

plugins/libplugin-pay.c:2006–2031  ·  view source on GitHub ↗

A payment is finished if a) it is in a final state, of b) it's in a * child-spawning state and all of its children are in a final state. */

Source from the content-addressed store, hash-verified

2004/* A payment is finished if a) it is in a final state, of b) it's in a
2005 * child-spawning state and all of its children are in a final state. */
2006static bool payment_is_finished(const struct payment *p)
2007{
2008top:
2009 if (p->step == PAYMENT_STEP_FAILED || p->step == PAYMENT_STEP_SUCCESS || p->abort)
2010 return true;
2011 else if (p->step == PAYMENT_STEP_SPLIT || p->step == PAYMENT_STEP_RETRY) {
2012 size_t num_children = tal_count(p->children);
2013
2014 /* Retry case will almost always have just one child, so avoid
2015 * the overhead of pushing and popping off the C stack and
2016 * tail-recurse manually. */
2017 if (num_children == 1) {
2018 p = p->children[0];
2019 goto top;
2020 }
2021
2022 for (size_t i = 0; i < num_children; i++)
2023 /* In other words: if any child is unfinished,
2024 * we are unfinished. */
2025 if (!payment_is_finished(p->children[i]))
2026 return false;
2027 return true;
2028 } else {
2029 return false;
2030 }
2031}
2032
2033static enum payment_step payment_aggregate_states(struct payment *p)
2034{

Callers 1

payment_child_finishedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected