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

Function db_datastore_get

wallet/datastore.c:54–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54u8 *db_datastore_get(const tal_t *ctx,
55 struct db *db,
56 const char **key,
57 u64 *generation)
58{
59 struct db_stmt *stmt;
60 u8 *ret;
61
62 stmt = db_prepare_v2(db,
63 SQL("SELECT data, generation"
64 " FROM datastore"
65 " WHERE key = ?"));
66 db_bind_datastore_key(stmt, key);
67 db_query_prepared(stmt);
68
69 if (!db_step(stmt)) {
70 tal_free(stmt);
71 return NULL;
72 }
73
74 ret = db_col_arr(ctx, stmt, "data", u8);
75 if (generation)
76 *generation = db_col_u64(stmt, "generation");
77 else
78 db_col_ignore(stmt, "generation");
79 tal_free(stmt);
80 return ret;
81}
82
83static const char **db_col_datastore_key(const tal_t *ctx,
84 struct db_stmt *stmt,

Callers 2

wallet_datastore_getFunction · 0.70

Calls 6

db_query_preparedFunction · 0.85
db_stepFunction · 0.85
tal_freeFunction · 0.85
db_col_u64Function · 0.85
db_col_ignoreFunction · 0.85
db_bind_datastore_keyFunction · 0.70

Tested by

no test coverage detected