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

Function watch_check_block_added

lightningd/watch.c:579–604  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

577}
578
579void watch_check_block_added(const struct chain_topology *topo, u32 blockheight)
580{
581 struct blockdepthwatch_hash_iter it;
582
583 /* With ccan/htable, deleting during iteration is safe: adding isn't! */
584 blockdepthwatch_hash_lock(topo->blockdepthwatches);
585 for (struct blockdepthwatch *w = blockdepthwatch_hash_first(topo->blockdepthwatches, &it);
586 w;
587 w = blockdepthwatch_hash_next(topo->blockdepthwatches, &it)) {
588 /* You are not supposed to watch future blocks! */
589 assert(blockheight >= w->height);
590
591 u32 depth = blockheight - w->height + 1;
592 enum watch_result r = w->depthcb(topo->ld, depth, w->arg);
593
594 switch (r) {
595 case DELETE_WATCH:
596 tal_free(w);
597 continue;
598 case KEEP_WATCHING:
599 continue;
600 }
601 fatal("blockdepthwatch depth callback %p returned %i", w->depthcb, r);
602 }
603 blockdepthwatch_hash_unlock(topo->blockdepthwatches);
604}
605
606void watch_check_block_removed(const struct chain_topology *topo, u32 blockheight)
607{

Callers 1

updates_completeFunction · 0.85

Calls 2

tal_freeFunction · 0.85
fatalFunction · 0.70

Tested by

no test coverage detected