From ac9ecaca12fdcfdefb76ec0d8ca257a1dc91313e Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Sun, 24 Mar 2024 18:26:00 -0600 Subject: [PATCH] shardtree: Add `InsertionError::MarkedRetentionInvalid` --- shardtree/CHANGELOG.md | 9 ++++++--- shardtree/src/error.rs | 10 +++++----- shardtree/src/lib.rs | 3 +-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/shardtree/CHANGELOG.md b/shardtree/CHANGELOG.md index fc8e49a..694aff9 100644 --- a/shardtree/CHANGELOG.md +++ b/shardtree/CHANGELOG.md @@ -7,17 +7,20 @@ and this project adheres to Rust's notion of ## Unreleased -## Added +### Added - `ShardTree::{store, store_mut}` - `ShardTree::insert_frontier` +### Changed +- `shardtree::error::InsertionError` has new variant `MarkedRetentionInvalid` + ## [0.2.0] - 2023-11-07 -## Added +### Added - `ShardTree::{root_at_checkpoint_id, root_at_checkpoint_id_caching}` - `ShardTree::{witness_at_checkpoint_id, witness_at_checkpoint_id_caching}` -## Changed +### Changed - `ShardTree::root_at_checkpoint` and `ShardTree::root_at_checkpoint_caching` have been renamed to `root_at_checkpoint_depth` and `root_at_checkpoint_depth_caching`, respectively. diff --git a/shardtree/src/error.rs b/shardtree/src/error.rs index df6e965..2debfb7 100644 --- a/shardtree/src/error.rs +++ b/shardtree/src/error.rs @@ -80,8 +80,7 @@ pub enum InsertionError { InputMalformed(Address), // The caller attempted to mark the empty tree state as corresponding to the state // for a spendable note. - // TODO: Add this proper error type for `shardtree-0.3.0` - //MarkedRetentionInvalid, + MarkedRetentionInvalid, } impl fmt::Display for InsertionError { @@ -108,9 +107,10 @@ impl fmt::Display for InsertionError { InsertionError::TreeFull => write!(f, "Note commitment tree is full."), InsertionError::InputMalformed(addr) => { write!(f, "Input malformed for insertion at address {:?}", addr) - } //InsertionError::MarkedRetentionInvalid => { - // write!(f, "Cannot use `Marked` retention for the empty tree.") - //} + } + InsertionError::MarkedRetentionInvalid => { + write!(f, "Cannot use `Marked` retention for the empty tree.") + } } } } diff --git a/shardtree/src/lib.rs b/shardtree/src/lib.rs index 1e7073b..1f4510a 100644 --- a/shardtree/src/lib.rs +++ b/shardtree/src/lib.rs @@ -292,8 +292,7 @@ impl< is_marked: true, .. } | Retention::Marked => Err(ShardTreeError::Insert( - //TODO: use InsertionError::MarkedRetentionInvalid for `shardtree-0.3.0` - InsertionError::CheckpointOutOfOrder, + InsertionError::MarkedRetentionInvalid, )), } }