aboutsummaryrefslogtreecommitdiff
path: root/iomt.h
diff options
context:
space:
mode:
authorFranklin Wei <me@fwei.tk>2018-06-27 17:30:15 -0400
committerFranklin Wei <me@fwei.tk>2018-06-27 17:30:15 -0400
commit7c71372ec3a6a5b67e59feceeb9df23150ba77e9 (patch)
treeaf333f7d3b33601df6b6f336c604df99436f1e1e /iomt.h
parent1e3acc575e82210955774897eecbe0c5567b10ca (diff)
downloadcsaa-7c71372ec3a6a5b67e59feceeb9df23150ba77e9.zip
csaa-7c71372ec3a6a5b67e59feceeb9df23150ba77e9.tar.gz
csaa-7c71372ec3a6a5b67e59feceeb9df23150ba77e9.tar.bz2
csaa-7c71372ec3a6a5b67e59feceeb9df23150ba77e9.tar.xz
WIP on database backend
Diffstat (limited to 'iomt.h')
-rw-r--r--iomt.h72
1 files changed, 40 insertions, 32 deletions
diff --git a/iomt.h b/iomt.h
index 8ccd0dc..2162bd6 100644
--- a/iomt.h
+++ b/iomt.h
@@ -7,43 +7,51 @@ struct iomt_node {
hash_t val; /* all zero indicates placeholder */
};
+/* indices cannot be zero */
+static const struct iomt_node node_null = { 0, 0, hash_null };
+
+/* Each level of the IOMT is stored sequentially from left to
+ * right, top to bottom, as follows:
+ *
+ * [0]: root
+ * [1]: root left child
+ * [2]: root right child
+ * [3]: left child of [1]
+ * [4]: right child of [1]
+ * [5]: left child of [2]
+ * [6]: right child of [2],
+ *
+ * and so on.
+ */
struct iomt {
- bool in_memory;
-
- void *db;
- const char *nodes_table, leaves_table;
-
- /* the IOMT code will use nodes with key1_name = key1_val and (if
- * not NULL) key2_name = key2_val */
- const char *key1_name, *key2_name;
- int key1_val, key2_val;
-
int mt_leafcount, mt_logleaves; /* mt_logleaves must equal 2^mt_leafcount */
- /* The following members are valid only if in_memory ==
- * true... really should use a union here: */
-
- /* Each level of the IOMT is stored sequentially from left to
- * right, top to bottom, as follows:
- *
- * [0]: root
- * [1]: root left child
- * [2]: root right child
- * [3]: left child of [1]
- * [4]: right child of [1]
- * [5]: left child of [2]
- * [6]: right child of [2],
- *
- * and so on.
- */
- hash_t *mt_nodes; /* this has 2 * mt_leafcount - 1 elements. Note
- * that the bottom level consists of hashes of
- * the leaf nodes. */
-
- struct iomt_node *mt_leaves;
+ bool in_memory;
+
+ union {
+ struct {
+ void *db;
+ const char *nodes_table, *leaves_table;
+
+ /* the IOMT code will use nodes with key1_name = key1_val and (if
+ * not NULL) key2_name = key2_val */
+ const char *key1_name, *key2_name;
+ int key1_val, key2_val;
+ } db;
+ struct {
+ hash_t *mt_nodes; /* this has 2 * mt_leafcount - 1 elements. Note
+ * that the bottom level consists of hashes of
+ * the leaf nodes. */
+
+ struct iomt_node *mt_leaves;
+ } mem;
+ };
};
-hash_t hash_node(const struct iomt_node *node);
+hash_t hash_node(struct iomt_node node);
+
+hash_t *lookup_nodes(const struct iomt *tree, const int *indices, int n);
+void restore_nodes(struct iomt *tree, const int *indices, const hash_t *values, int n);
hash_t *merkle_complement(const struct iomt *tree, int leafidx, int **orders);