| 62 | } |
| 63 | |
| 64 | void add_blockheight(struct command *cmd, |
| 65 | struct bkpr *bkpr, |
| 66 | const struct bitcoin_txid *txid, |
| 67 | u32 blockheight) |
| 68 | { |
| 69 | struct blockheights *bh = bkpr->blockheights; |
| 70 | struct blockheight_entry *e; |
| 71 | be32 be_blockheight; |
| 72 | const char **path = ds_blockheight_path(tmpctx, txid); |
| 73 | |
| 74 | /* Update in-memory map (replace or insert) */ |
| 75 | e = blockheight_htable_get(bh->map, txid); |
| 76 | if (e) { |
| 77 | e->height = blockheight; |
| 78 | } else { |
| 79 | e = tal(bh->map, struct blockheight_entry); |
| 80 | e->txid = *txid; |
| 81 | e->height = blockheight; |
| 82 | blockheight_htable_add(bh->map, e); |
| 83 | } |
| 84 | |
| 85 | be_blockheight = cpu_to_be32(blockheight); |
| 86 | jsonrpc_set_datastore_binary(cmd, path, |
| 87 | &be_blockheight, sizeof(be_blockheight), |
| 88 | "create-or-replace", |
| 89 | ignore_datastore_reply, NULL, NULL); |
| 90 | } |
| 91 | |
| 92 | u32 find_blockheight(const struct bkpr *bkpr, |
| 93 | const struct bitcoin_txid *txid) |
no test coverage detected