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

Function add_blockheight

plugins/bkpr/blockheights.c:64–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64void 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
92u32 find_blockheight(const struct bkpr *bkpr,
93 const struct bitcoin_txid *txid)

Callers 1

Calls 2

ds_blockheight_pathFunction · 0.85
cpu_to_be32Function · 0.85

Tested by

no test coverage detected