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

Function assign_blame

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

1505 * node, whose errors are treated differently.
1506 */
1507static bool assign_blame(const struct payment *p,
1508 const struct node_id **errnode,
1509 const struct route_hop **errchan)
1510{
1511 int index;
1512
1513 if (p->result->erring_index == NULL)
1514 return false;
1515
1516 index = *p->result->erring_index;
1517
1518 /* BADONION errors are reported on behalf of the next node. */
1519 if (p->result->failcode & BADONION)
1520 index++;
1521
1522 /* Final node *shouldn't* report BADONION, but don't assume. */
1523 if (index >= tal_count(p->route)) {
1524 *errchan = NULL;
1525 *errnode = &p->route[tal_count(p->route) - 1].node_id;
1526 return true;
1527 }
1528
1529 *errchan = &p->route[index];
1530 if (index == 0)
1531 *errnode = p->local_id;
1532 else
1533 *errnode = &p->route[index - 1].node_id;
1534 return true;
1535}
1536
1537/* Fix up the channel_update to include the type if it doesn't currently have
1538 * one. See ElementsProject/lightning#1730 and lightningnetwork/lnd#1599 for the

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected