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

Function payment_is_finished

plugins/libplugin-pay.c:1771–1796  ·  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

1769/* A payment is finished if a) it is in a final state, of b) it's in a
1770 * child-spawning state and all of its children are in a final state. */
1771static bool payment_is_finished(const struct payment *p)
1772{
1773top:
1774 if (p->step == PAYMENT_STEP_FAILED || p->step == PAYMENT_STEP_SUCCESS || p->abort)
1775 return true;
1776 else if (p->step == PAYMENT_STEP_SPLIT || p->step == PAYMENT_STEP_RETRY) {
1777 size_t num_children = tal_count(p->children);
1778
1779 /* Retry case will almost always have just one child, so avoid
1780 * the overhead of pushing and popping off the C stack and
1781 * tail-recurse manually. */
1782 if (num_children == 1) {
1783 p = p->children[0];
1784 goto top;
1785 }
1786
1787 for (size_t i = 0; i < num_children; i++)
1788 /* In other words: if any child is unfinished,
1789 * we are unfinished. */
1790 if (!payment_is_finished(p->children[i]))
1791 return false;
1792 return true;
1793 } else {
1794 return false;
1795 }
1796}
1797
1798static enum payment_step payment_aggregate_states(struct payment *p)
1799{

Callers 1

payment_child_finishedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected