|
@ -492,17 +492,29 @@ impl TryFrom for LeafIndex { |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl<const DEPTH: u8> Serializable for LeafIndex<DEPTH> {
|
|
|
|
|
|
fn write_into<W: ByteWriter>(&self, target: &mut W) {
|
|
|
|
|
|
self.index.write_into(target);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl<const DEPTH: u8> Deserializable for LeafIndex<DEPTH> {
|
|
|
|
|
|
fn read_from<R: ByteReader>(source: &mut R) -> Result<Self, DeserializationError> {
|
|
|
|
|
|
Ok(Self { index: source.read()? })
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
// MUTATIONS
|
|
|
// MUTATIONS
|
|
|
// ================================================================================================
|
|
|
// ================================================================================================
|
|
|
|
|
|
|
|
|
/// A change to an inner node of a [`SparseMerkleTree`] that hasn't yet been applied.
|
|
|
|
|
|
|
|
|
/// A change to an inner node of a sparse Merkle tree that hasn't yet been applied.
|
|
|
/// [`MutationSet`] stores this type in relation to a [`NodeIndex`] to keep track of what changes
|
|
|
/// [`MutationSet`] stores this type in relation to a [`NodeIndex`] to keep track of what changes
|
|
|
/// need to occur at which node indices.
|
|
|
/// need to occur at which node indices.
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
|
pub enum NodeMutation {
|
|
|
pub enum NodeMutation {
|
|
|
/// Corresponds to [`SparseMerkleTree::remove_inner_node()`].
|
|
|
|
|
|
|
|
|
/// Node needs to be removed.
|
|
|
Removal,
|
|
|
Removal,
|
|
|
/// Corresponds to [`SparseMerkleTree::insert_inner_node()`].
|
|
|
|
|
|
|
|
|
/// Node needs to be inserted.
|
|
|
Addition(InnerNode),
|
|
|
Addition(InnerNode),
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|