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

Function assign_blame

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

1361 * node, whose errors are treated differently.
1362 */
1363static bool assign_blame(const struct payment *p,
1364 const struct node_id **errnode,
1365 const struct route_hop **errchan)
1366{
1367 int index;
1368
1369 if (p->result->erring_index == NULL)
1370 return false;
1371
1372 index = *p->result->erring_index;
1373
1374 /* BADONION errors are reported on behalf of the next node. */
1375 if (p->result->failcode & BADONION)
1376 index++;
1377
1378 /* Final node *shouldn't* report BADONION, but don't assume. */
1379 if (index >= tal_count(p->route)) {
1380 *errchan = NULL;
1381 *errnode = &p->route[tal_count(p->route) - 1].node_id;
1382 return true;
1383 }
1384
1385 *errchan = &p->route[index];
1386 if (index == 0)
1387 *errnode = p->local_id;
1388 else
1389 *errnode = &p->route[index - 1].node_id;
1390 return true;
1391}
1392
1393/* Fix up the channel_update to include the type if it doesn't currently have
1394 * one. See ElementsProject/lightning#1730 and lightningnetwork/lnd#1599 for the

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected