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

Function assign_blame

plugins/libplugin-pay.c:1523–1551  ·  view source on GitHub ↗

From the docs: * * - *erring_index*: The index of the node along the route that * reported the error. 0 for the local node, 1 for the first hop, * and so on. * * The only difficulty is mapping the erring_index to the correct hop. * We split into the erring node, and the error channel, since they're * used in different contexts. NULL error_channel means it's the final * node, whose err

Source from the content-addressed store, hash-verified

1521 * node, whose errors are treated differently.
1522 */
1523static bool assign_blame(const struct payment *p,
1524 const struct node_id **errnode,
1525 const struct route_hop **errchan)
1526{
1527 int index;
1528
1529 if (p->result->erring_index == NULL)
1530 return false;
1531
1532 index = *p->result->erring_index;
1533
1534 /* BADONION errors are reported on behalf of the next node. */
1535 if (p->result->failcode & BADONION)
1536 index++;
1537
1538 /* Final node *shouldn't* report BADONION, but don't assume. */
1539 if (index >= tal_count(p->route)) {
1540 *errchan = NULL;
1541 *errnode = &p->route[tal_count(p->route) - 1].node_id;
1542 return true;
1543 }
1544
1545 *errchan = &p->route[index];
1546 if (index == 0)
1547 *errnode = p->local_id;
1548 else
1549 *errnode = &p->route[index - 1].node_id;
1550 return true;
1551}
1552
1553/* Fix up the channel_update to include the type if it doesn't currently have
1554 * one. See ElementsProject/lightning#1730 and lightningnetwork/lnd#1599 for the

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected