mod.rs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* This file is part of DarkFi (https://dark.fi)
  2. *
  3. * Copyright (C) 2020-2026 Dyne.org foundation
  4. * Copyright (C) 2021 MONOLOG (Taeho Francis Lim and Jongwhan Lee) MIT License
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as
  8. * published by the Free Software Foundation, either version 3 of the
  9. * License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. /// Size of fixed length byte-array from a `Hasher`.
  20. /// Equivalent to `key` length of the tree.
  21. pub const HASH_LEN: usize = 32;
  22. /// A type representing length of `Bits`
  23. pub type BitsLen = u16;
  24. /// Type indicating fixed length byte-array.
  25. pub type Hash = [u8; HASH_LEN];
  26. /// Type representing a Merkle proof
  27. pub type Proof = Vec<(bool, Vec<u8>)>;
  28. /// The key to be used to restore the latest `root`
  29. pub const ROOT_KEY: &Hash = b"_______monotree::headroot_______";
  30. use std::sync::LazyLock;
  31. pub static EMPTY_HASH: LazyLock<Hash> = LazyLock::new(|| *blake3::hash(&[]).as_bytes());
  32. pub mod bits;
  33. pub mod node;
  34. pub mod tree;
  35. pub use tree::{KvdbOverlayDb, KvdbTreeDb, MemoryDb, Monotree};
  36. pub mod utils;
  37. #[cfg(test)]
  38. mod tests;