chore(rln): expose seq_atomic_operation api (#206)

This commit is contained in:
Aaryamann Challani 2023-08-21 12:07:57 +05:30 committed by GitHub
parent bf3d1d3309
commit c6c1bfde91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -294,6 +294,22 @@ pub extern "C" fn atomic_operation(
call!(ctx, atomic_operation, index, leaves_buffer, indices_buffer) call!(ctx, atomic_operation, index, leaves_buffer, indices_buffer)
} }
#[allow(clippy::not_unsafe_ptr_arg_deref)]
#[no_mangle]
pub extern "C" fn seq_atomic_operation(
ctx: *mut RLN,
leaves_buffer: *const Buffer,
indices_buffer: *const Buffer,
) -> bool {
call!(
ctx,
atomic_operation,
ctx.process().leaves_set(),
leaves_buffer,
indices_buffer
)
}
#[allow(clippy::not_unsafe_ptr_arg_deref)] #[allow(clippy::not_unsafe_ptr_arg_deref)]
#[no_mangle] #[no_mangle]
pub extern "C" fn get_root(ctx: *const RLN, output_buffer: *mut Buffer) -> bool { pub extern "C" fn get_root(ctx: *const RLN, output_buffer: *mut Buffer) -> bool {

View File

@ -406,6 +406,10 @@ impl RLN<'_> {
Ok(()) Ok(())
} }
pub fn leaves_set(&mut self) -> usize {
self.tree.leaves_set()
}
/// Sets a leaf value at the next available never-set leaf index. /// Sets a leaf value at the next available never-set leaf index.
/// ///
/// This function updates the internal Merkle tree `next_index` value indicating the next available index corresponding to a never-set leaf as `next_index = next_index + 1`. /// This function updates the internal Merkle tree `next_index` value indicating the next available index corresponding to a never-set leaf as `next_index = next_index + 1`.