Skip to content

Commit

Permalink
feat: improve doc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tomyrd committed Jul 25, 2024
1 parent 81225ce commit 73feb0f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
5 changes: 4 additions & 1 deletion crates/store/src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ impl Db {
})?
}

/// Loads the nullifiers that match the prefixes from the DB.
pub async fn select_nullifiers_by_prefix(
&self,
prefix_len: u32,
Expand All @@ -171,7 +172,9 @@ impl Db {
self.pool
.get()
.await?
.interact(move |conn| sql::select_nullifiers_by_prefix(conn, prefix_len, &nullifier_prefixes))
.interact(move |conn| {
sql::select_nullifiers_by_prefix(conn, prefix_len, &nullifier_prefixes)
})
.await
.map_err(|err| {
DatabaseError::InteractError(format!(
Expand Down
11 changes: 11 additions & 0 deletions crates/store/src/db/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,17 @@ pub fn select_nullifiers_by_block_range(
Ok(result)
}

/// Select nullifiers created that match the `nullifier_prefixes` filter using the given
/// [Connection].
///
/// Each value of the `nullifier_prefixes` is only the `prefix_len` most significant bits
/// of the nullifier of interest to the client. This hides the details of the specific
/// nullifier being requested.
///
/// # Returns
///
/// A vector of [NullifierInfo] with the nullifiers and the block height at which they were
/// created, or an error.
pub fn select_nullifiers_by_prefix(
conn: &mut Connection,
_prefix_len: u32,
Expand Down
3 changes: 3 additions & 0 deletions crates/store/src/server/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ impl api_server::Api for StoreApi {
Ok(Response::new(CheckNullifiersResponse { proofs: convert(proofs) }))
}

/// Returns nullifiers that match the specified prefixes and have been consumed.
///
/// Currently the only supported prefix length is 16 bits.
#[instrument(
target = "miden-store",
name = "store:check_nullifiers_by_prefix",
Expand Down
4 changes: 2 additions & 2 deletions proto/requests.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ message ApplyBlockRequest {
bytes block = 1;
}

// Returns a list of nullifiers recorded in the node
// Returns a list of nullifiers that match the specified prefixes and are recorded in the node.
message CheckNullifiersByPrefixRequest {
// Number of bits used for nullifier prefix.
// Number of bits used for nullifier prefix. Currently the only supported value is 16.
uint32 prefix_len = 1;
// List of nullifiers to check. Each nullifier is specified by its prefix with length equal
// to prefix_len
Expand Down

0 comments on commit 73feb0f

Please sign in to comment.