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

Function get_new_block

lightningd/chaintopology.c:1090–1121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1088}
1089
1090static void get_new_block(struct bitcoind *bitcoind,
1091 u32 height,
1092 struct bitcoin_blkid *blkid,
1093 struct bitcoin_block *blk,
1094 struct chain_topology *topo)
1095{
1096 if (!blkid && !blk) {
1097 /* No such block, we're done. */
1098 updates_complete(topo);
1099 trace_span_end(topo);
1100 return;
1101 }
1102 assert(blkid && blk);
1103
1104 /* Annotate all transactions with the chainparams */
1105 for (size_t i = 0; i < tal_count(blk->tx); i++)
1106 blk->tx[i]->chainparams = chainparams;
1107
1108 /* Unexpected predecessor? Free predecessor, refetch it. */
1109 if (!bitcoin_blkid_eq(&topo->tip->blkid, &blk->hdr.prev_hash))
1110 remove_tip(topo);
1111 else {
1112 add_tip(topo, new_block(topo, blk, height));
1113
1114 /* tell plugins a new block was processed */
1115 notify_block_added(topo->ld, topo->tip);
1116 }
1117
1118 /* Try for next one. */
1119 trace_span_end(topo);
1120 try_extend_tip(topo);
1121}
1122
1123static void try_extend_tip(struct chain_topology *topo)
1124{

Callers

nothing calls this directly

Calls 7

updates_completeFunction · 0.85
trace_span_endFunction · 0.85
remove_tipFunction · 0.85
add_tipFunction · 0.85
new_blockFunction · 0.85
try_extend_tipFunction · 0.85
notify_block_addedFunction · 0.70

Tested by

no test coverage detected