Once we're run out of new blocks to add, call this. */
| 590 | |
| 591 | /* Once we're run out of new blocks to add, call this. */ |
| 592 | static void updates_complete(struct chain_topology *topo) |
| 593 | { |
| 594 | if (!bitcoin_blkid_eq(&topo->tip->blkid, &topo->prev_tip)) { |
| 595 | /* Tell watch code to re-evaluate all txs. */ |
| 596 | watch_topology_changed(topo); |
| 597 | |
| 598 | /* Tell lightningd about new block. */ |
| 599 | notify_new_block(topo->bitcoind->ld, topo->tip->height); |
| 600 | |
| 601 | /* Maybe need to rebroadcast. */ |
| 602 | rebroadcast_txs(topo); |
| 603 | |
| 604 | /* We've processed these UTXOs */ |
| 605 | db_set_intvar(topo->bitcoind->ld->wallet->db, |
| 606 | "last_processed_block", topo->tip->height); |
| 607 | |
| 608 | topo->prev_tip = topo->tip->blkid; |
| 609 | |
| 610 | /* Send out an account balance snapshot */ |
| 611 | if (!first_update_complete) { |
| 612 | send_account_balance_snapshot(topo->ld, topo->tip->height); |
| 613 | first_update_complete = true; |
| 614 | } |
| 615 | } |
| 616 | |
| 617 | /* If bitcoind is synced, we're now synced. */ |
| 618 | if (topo->bitcoind->synced && !topology_synced(topo)) { |
| 619 | struct sync_waiter *w; |
| 620 | struct list_head *list = topo->sync_waiters; |
| 621 | |
| 622 | /* Mark topology_synced() before callbacks. */ |
| 623 | topo->sync_waiters = NULL; |
| 624 | |
| 625 | while ((w = list_pop(list, struct sync_waiter, list))) { |
| 626 | /* In case it doesn't free itself. */ |
| 627 | tal_del_destructor(w, destroy_sync_waiter); |
| 628 | tal_steal(list, w); |
| 629 | w->cb(topo, w->arg); |
| 630 | } |
| 631 | tal_free(list); |
| 632 | } |
| 633 | |
| 634 | /* Try again soon. */ |
| 635 | next_topology_timer(topo); |
| 636 | } |
| 637 | |
| 638 | static void record_wallet_spend(struct lightningd *ld, |
| 639 | struct bitcoin_outpoint *outpoint, |
no test coverage detected