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

Function updates_complete

lightningd/chaintopology.c:878–925  ·  view source on GitHub ↗

Once we're run out of new blocks to add, call this. */

Source from the content-addressed store, hash-verified

876
877/* Once we're run out of new blocks to add, call this. */
878static void updates_complete(struct chain_topology *topo)
879{
880 if (!bitcoin_blkid_eq(&topo->tip->blkid, &topo->prev_tip)) {
881 /* Tell lightningd about new block. */
882 notify_new_block(topo->bitcoind->ld);
883
884 /* Tell blockdepth watchers */
885 watch_check_block_added(topo, topo->tip->height);
886
887 /* Tell watch code to re-evaluate all txs. */
888 watch_topology_changed(topo);
889
890 /* Maybe need to rebroadcast. */
891 rebroadcast_txs(topo);
892
893 /* We've processed these UTXOs */
894 db_set_intvar(topo->bitcoind->ld->wallet->db,
895 "last_processed_block", topo->tip->height);
896
897 topo->prev_tip = topo->tip->blkid;
898
899 /* Send out an account balance snapshot */
900 if (!first_update_complete) {
901 send_account_balance_snapshot(topo->ld);
902 first_update_complete = true;
903 }
904 }
905
906 /* If bitcoind is synced, we're now synced. */
907 if (topo->bitcoind->synced && !topology_synced(topo)) {
908 struct sync_waiter *w;
909 struct list_head *list = topo->sync_waiters;
910
911 /* Mark topology_synced() before callbacks. */
912 topo->sync_waiters = NULL;
913
914 while ((w = list_pop(list, struct sync_waiter, list))) {
915 /* In case it doesn't free itself. */
916 tal_del_destructor(w, destroy_sync_waiter);
917 tal_steal(list, w);
918 w->cb(topo, w->arg);
919 }
920 tal_free(list);
921 }
922
923 /* Try again soon. */
924 next_topology_timer(topo);
925}
926
927static void record_wallet_spend(struct lightningd *ld,
928 const struct bitcoin_outpoint *outpoint,

Callers 1

get_new_blockFunction · 0.85

Calls 9

notify_new_blockFunction · 0.85
watch_check_block_addedFunction · 0.85
watch_topology_changedFunction · 0.85
rebroadcast_txsFunction · 0.85
db_set_intvarFunction · 0.85
topology_syncedFunction · 0.85
tal_freeFunction · 0.85
next_topology_timerFunction · 0.85

Tested by

no test coverage detected