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

Function get_new_block

lightningd/chaintopology.c:798–826  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

796}
797
798static void get_new_block(struct bitcoind *bitcoind,
799 struct bitcoin_blkid *blkid,
800 struct bitcoin_block *blk,
801 struct chain_topology *topo)
802{
803 if (!blkid && !blk) {
804 /* No such block, we're done. */
805 updates_complete(topo);
806 return;
807 }
808 assert(blkid && blk);
809
810 /* Annotate all transactions with the chainparams */
811 for (size_t i = 0; i < tal_count(blk->tx); i++)
812 blk->tx[i]->chainparams = chainparams;
813
814 /* Unexpected predecessor? Free predecessor, refetch it. */
815 if (!bitcoin_blkid_eq(&topo->tip->blkid, &blk->hdr.prev_hash))
816 remove_tip(topo);
817 else {
818 add_tip(topo, new_block(topo, blk, topo->tip->height + 1));
819
820 /* tell plugins a new block was processed */
821 notify_block_added(topo->ld, topo->tip);
822 }
823
824 /* Try for next one. */
825 try_extend_tip(topo);
826}
827
828static void try_extend_tip(struct chain_topology *topo)
829{

Callers

nothing calls this directly

Calls 6

updates_completeFunction · 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