brine_tree/
utils.rs

1use super::hash::Hash;
2use super::error::{ProgramError, ProgramResult};
3
4#[inline]
5pub fn hash(data: &[u8]) -> Hash {
6    Hash::new_from_array(hashv(&[data]).into())
7}
8
9#[inline]
10pub fn hashv(data: &[&[u8]]) -> Hash {
11    let res = solana_program::hash::hashv(data);
12    Hash::new_from_array(res.to_bytes())
13}
14
15#[inline]
16pub fn check_condition(condition: bool, msg: &'static str) -> ProgramResult {
17    if condition {
18        Ok(())
19    } else {
20        Err(ProgramError::Custom(msg))
21    }
22}