]> git.ozlabs.org Git - ccan/blobdiff - ccan/crypto/shachain/shachain.h
shachain: add shachain_next_index()
[ccan] / ccan / crypto / shachain / shachain.h
index 90f2380ed39b89d8277db3542e669fcc22f7176e..8eabbab457a72b49c2c47736ce6e7d19f0b8fe82 100644 (file)
@@ -71,20 +71,28 @@ struct shachain {
  */
 void shachain_init(struct shachain *chain);
 
  */
 void shachain_init(struct shachain *chain);
 
+/**
+ * shachain_next_index - what's the next index I can add to the shachain?
+ * @chain: the chain
+ *
+ * This returns 0xFFFFFFFFFFFFFFFF (for a freshly
+ * initialized chain), or one less than the previously successfully
+ * added value.
+ */
+shachain_index_t shachain_next_index(const struct shachain *chain);
+
 /**
  * shachain_add_hash - record the hash for the next index.
  * @chain: the chain to add to
  * @index: the index of the hash
  * @hash: the hash value.
  *
 /**
  * shachain_add_hash - record the hash for the next index.
  * @chain: the chain to add to
  * @index: the index of the hash
  * @hash: the hash value.
  *
- * You can only add index 0xFFFFFFFFFFFFFFFF (for a freshly
- * initialized chain), or one less than the previously successfully
- * added value.
+ * You can only add shachain_next_index(@chain).
  *
  * This can fail (return false without altering @chain) if the hash
  * for this index isn't consistent with previous hashes (ie. wasn't
  * generated from the same seed), though it can't always detect that.
  *
  * This can fail (return false without altering @chain) if the hash
  * for this index isn't consistent with previous hashes (ie. wasn't
  * generated from the same seed), though it can't always detect that.
- * If the hash is inconsistent yet undetected, the next addition will
+ * If the hash is inconsistent yet undetected, a future addition will
  * fail.
  *
  * Example:
  * fail.
  *
  * Example: