Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion miden-crypto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#[macro_use]
extern crate alloc;

#[cfg(feature = "std")]
extern crate std;

Expand Down Expand Up @@ -49,6 +48,20 @@ pub type Map<K, V> = alloc::collections::BTreeMap<K, V>;
#[cfg(not(feature = "hashmaps"))]
pub use alloc::collections::btree_map::Entry as MapEntry;

/// An alias for a simple set.
///
/// By default, this is an alias for the [`alloc::collections::BTreeSet`]. However, when the
/// `hashmaps` feature is enabled, this becomes an alias for hashbrown's HashSet.
#[cfg(feature = "hashmaps")]
pub type Set<V> = hashbrown::HashSet<V>;

/// An alias for a simple set.
///
/// By default, this is an alias for the [`alloc::collections::BTreeSet`]. However, when the
/// `hashmaps` feature is enabled, this becomes an alias for hashbrown's HashSet.
#[cfg(not(feature = "hashmaps"))]
pub type Set<V> = alloc::collections::BTreeSet<V>;

// CONSTANTS
// ================================================================================================

Expand Down
21 changes: 21 additions & 0 deletions miden-crypto/src/merkle/smt/large_forest/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//! This module contains the error types and helpers for working with errors from the large SMT
//! forest.

use thiserror::Error;

use crate::merkle::{MerkleError, smt::large_forest::history::error::HistoryError};

/// The errors returned by operations on the large SMT forest.
///
/// This type primarily serves to wrap more specific error types from various subsystems into a
/// generic interface type.
#[derive(Debug, Error)]
pub enum LargeSmtForestError {
#[error(transparent)]
HistoryError(#[from] HistoryError),

#[error(transparent)]
MerkleError(#[from] MerkleError),
}

pub mod history {}
23 changes: 23 additions & 0 deletions miden-crypto/src/merkle/smt/large_forest/history/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//! The error type and utility types for working with errors from the SMT history construct.
use thiserror::Error;

use crate::merkle::smt::large_forest::history::VersionId;

/// The type of errors returned by the history container.
#[derive(Debug, Error, PartialEq)]
pub enum HistoryError {
/// Raised when a query expects the history to contain at least one entry, but it is empty.
#[error("The history was empty")]
HistoryEmpty,

/// Raised when a version is added to the history and is not newer than the previous.
#[error("Version {0} is not monotonic with respect to {1}")]
NonMonotonicVersions(VersionId, VersionId),

/// Raised when no version exists in the history for an arbitrary query.
#[error("The specified version is too old to be served by the history")]
VersionTooOld,
}

/// The result type for use within the history container.
pub type Result<T> = core::result::Result<T, HistoryError>;
Loading
Loading