You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fnget_root_at_index(tree_bytes:&[u8],max_depth:usize,max_buffer_size:usize,current_index:usize,) -> Result<[u8;32],&'static str>{// Assuming the root is 32 bytesif current_index >= max_buffer_size {returnErr("Current index is out of bounds");}// Size of each field in ChangeLoglet node_size = 32;// Assuming size of Node is 32 byteslet u32_size = 4;// Size of u32// Size of ChangeLoglet changelog_size = node_size + (node_size * max_depth) + u32_size + u32_size;// Calculate the starting position of the ChangeLog at the current indexlet changelog_start = (8 + 8 + 8) + (changelog_size * current_index);let root_start = changelog_start;// Root is the first element in ChangeLog// Extract the root byteslet root_bytes = &tree_bytes[root_start..root_start + node_size];// Convert the bytes to a 32-byte array
root_bytes.try_into().map_err(|_| "Failed to extract root")}
Features:
Implementation details:
emit_cpi!
instead ofnoop
cpinoop
in instructionsThe text was updated successfully, but these errors were encountered: