| 796 | } |
| 797 | |
| 798 | static 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 | |
| 828 | static void try_extend_tip(struct chain_topology *topo) |
| 829 | { |
nothing calls this directly
no test coverage detected