| 3775 | } |
| 3776 | |
| 3777 | void wallet_block_add(struct wallet *w, struct block *b) |
| 3778 | { |
| 3779 | struct db_stmt *stmt = |
| 3780 | db_prepare_v2(w->db, SQL("INSERT INTO blocks " |
| 3781 | "(height, hash, prev_hash) " |
| 3782 | "VALUES (?, ?, ?);")); |
| 3783 | db_bind_int(stmt, 0, b->height); |
| 3784 | db_bind_sha256d(stmt, 1, &b->blkid.shad); |
| 3785 | if (b->prev) { |
| 3786 | db_bind_sha256d(stmt, 2, &b->prev->blkid.shad); |
| 3787 | }else { |
| 3788 | db_bind_null(stmt, 2); |
| 3789 | } |
| 3790 | db_exec_prepared_v2(take(stmt)); |
| 3791 | |
| 3792 | /* Now cleanup UTXOs that we don't care about anymore */ |
| 3793 | wallet_utxoset_prune(w, b->height); |
| 3794 | } |
| 3795 | |
| 3796 | void wallet_block_remove(struct wallet *w, struct block *b) |
| 3797 | { |