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

Function billboard_update

onchaind/onchaind.c:905–962  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

903}
904
905static void billboard_update(struct tracked_output **outs)
906{
907 const struct tracked_output *best = NULL;
908
909 /* Highest priority is to report on proposals we have */
910 for (size_t i = 0; i < tal_count(outs); i++) {
911 if (!outs[i]->proposal || outs[i]->resolved)
912 continue;
913 if (!best || prop_blockheight(outs[i]) < prop_blockheight(best))
914 best = outs[i];
915 }
916
917 if (best) {
918 /* If we've broadcast and not seen yet, this happens */
919 if (best->proposal->depth_required <= best->depth) {
920 peer_billboard(false,
921 "%u outputs unresolved: waiting confirmation that we spent %s (%s) using %s",
922 num_not_irrevocably_resolved(outs),
923 output_type_name(best->output_type),
924 fmt_bitcoin_outpoint(tmpctx, &best->outpoint),
925 tx_type_name(best->proposal->tx_type));
926 } else {
927 peer_billboard(false,
928 "%u outputs unresolved: in %u blocks will spend %s (%s) using %s",
929 num_not_irrevocably_resolved(outs),
930 best->proposal->depth_required - best->depth,
931 output_type_name(best->output_type),
932 fmt_bitcoin_outpoint(tmpctx, &best->outpoint),
933 tx_type_name(best->proposal->tx_type));
934 }
935 return;
936 }
937
938 /* Now, just report on the last thing we're waiting out. */
939 for (size_t i = 0; i < tal_count(outs); i++) {
940 /* FIXME: Can this happen? No proposal, no resolution? */
941 if (!outs[i]->resolved)
942 continue;
943 if (!best || outs[i]->resolved->depth < best->resolved->depth)
944 best = outs[i];
945 }
946
947 if (best) {
948 peer_billboard(false,
949 "All outputs resolved:"
950 " waiting %u more blocks before forgetting"
951 " channel",
952 best->resolved->depth < 100
953 ? 100 - best->resolved->depth : 0);
954 return;
955 }
956
957 /* Not sure this can happen, but take last one (there must be one!) */
958 best = outs[tal_count(outs)-1];
959 peer_billboard(false, "%u outputs unresolved: %s is one (depth %u)",
960 num_not_irrevocably_resolved(outs),
961 output_type_name(best->output_type), best->depth);
962}

Callers 1

wait_for_resolvedFunction · 0.70

Calls 6

prop_blockheightFunction · 0.85
output_type_nameFunction · 0.85
fmt_bitcoin_outpointFunction · 0.85
tx_type_nameFunction · 0.85
peer_billboardFunction · 0.50

Tested by

no test coverage detected