| 1088 | } |
| 1089 | |
| 1090 | static 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 | |
| 1123 | static void try_extend_tip(struct chain_topology *topo) |
| 1124 | { |
nothing calls this directly
no test coverage detected