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

Function billboard_update

onchaind/onchaind.c:1425–1486  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1423}
1424
1425static void billboard_update(struct tracked_output **outs)
1426{
1427 const struct tracked_output *best = NULL;
1428
1429 /* Highest priority is to report on proposals we have */
1430 for (size_t i = 0; i < tal_count(outs); i++) {
1431 if (!outs[i]->proposal || outs[i]->resolved)
1432 continue;
1433 if (!best || prop_blockheight(outs[i]) < prop_blockheight(best))
1434 best = outs[i];
1435 }
1436
1437 if (best) {
1438 /* If we've broadcast and not seen yet, this happens */
1439 if (best->proposal->depth_required <= best->depth) {
1440 peer_billboard(false,
1441 "%u outputs unresolved: waiting confirmation that we spent %s (%s) using %s",
1442 num_not_irrevocably_resolved(outs),
1443 output_type_name(best->output_type),
1444 type_to_string(tmpctx,
1445 struct bitcoin_outpoint,
1446 &best->outpoint),
1447 tx_type_name(best->proposal->tx_type));
1448 } else {
1449 peer_billboard(false,
1450 "%u outputs unresolved: in %u blocks will spend %s (%s) using %s",
1451 num_not_irrevocably_resolved(outs),
1452 best->proposal->depth_required - best->depth,
1453 output_type_name(best->output_type),
1454 type_to_string(tmpctx,
1455 struct bitcoin_outpoint,
1456 &best->outpoint),
1457 tx_type_name(best->proposal->tx_type));
1458 }
1459 return;
1460 }
1461
1462 /* Now, just report on the last thing we're waiting out. */
1463 for (size_t i = 0; i < tal_count(outs); i++) {
1464 /* FIXME: Can this happen? No proposal, no resolution? */
1465 if (!outs[i]->resolved)
1466 continue;
1467 if (!best || outs[i]->resolved->depth < best->resolved->depth)
1468 best = outs[i];
1469 }
1470
1471 if (best) {
1472 peer_billboard(false,
1473 "All outputs resolved:"
1474 " waiting %u more blocks before forgetting"
1475 " channel",
1476 best->resolved->depth < 100
1477 ? 100 - best->resolved->depth : 0);
1478 return;
1479 }
1480
1481 /* Not sure this can happen, but take last one (there must be one!) */
1482 best = outs[tal_count(outs)-1];

Callers 1

wait_for_resolvedFunction · 0.70

Calls 6

prop_blockheightFunction · 0.85
output_type_nameFunction · 0.85
tx_type_nameFunction · 0.85
peer_billboardFunction · 0.50
type_to_stringClass · 0.50

Tested by

no test coverage detected