Skip to content

Commit

Permalink
feat: partial pollard
Browse files Browse the repository at this point in the history
Partial pollards allow you to hold only a subset of utxos in the forest,
effectively caching them and not requiring to download or validate extra
proofs for it.

This commit implements it using a very similar approach as the main
forest, but with the possibility to prune leaves that you don't want to
hold anymore.
  • Loading branch information
Davidson-Souza committed Dec 2, 2024
1 parent 2ca359f commit 16c754c
Show file tree
Hide file tree
Showing 5 changed files with 1,123 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/full-accumulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
use std::str::FromStr;

use rustreexo::accumulator::node_hash::NodeHash;
use rustreexo::accumulator::mem_forest::MemForest;
use rustreexo::accumulator::node_hash::NodeHash;
use rustreexo::accumulator::proof::Proof;
use rustreexo::accumulator::stump::Stump;

Expand Down
8 changes: 4 additions & 4 deletions src/accumulator/mem_forest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
//!
//! # Example
//! ```
//! use rustreexo::accumulator::node_hash::NodeHash;
//! use rustreexo::accumulator::mem_forest::MemForest;
//! use rustreexo::accumulator::node_hash::NodeHash;
//! let values = vec![0, 1, 2, 3, 4, 5, 6, 7];
//! let hashes: Vec<NodeHash> = values
//! .into_iter()
Expand Down Expand Up @@ -266,8 +266,8 @@ impl MemForest {
/// and the hashes that we what to prove, but sorted by position in the tree.
/// # Example
/// ```
/// use rustreexo::accumulator::node_hash::NodeHash;
/// use rustreexo::accumulator::mem_forest::MemForest;
/// use rustreexo::accumulator::node_hash::NodeHash;
/// let mut mem_forest = MemForest::new();
/// let hashes = vec![0, 1, 2, 3, 4, 5, 6, 7]
/// .iter()
Expand Down Expand Up @@ -308,8 +308,8 @@ impl MemForest {
/// use bitcoin_hashes::sha256::Hash as Data;
/// use bitcoin_hashes::Hash;
/// use bitcoin_hashes::HashEngine;
/// use rustreexo::accumulator::node_hash::NodeHash;
/// use rustreexo::accumulator::mem_forest::MemForest;
/// use rustreexo::accumulator::node_hash::NodeHash;
/// let values = vec![0, 1, 2, 3, 4, 5, 6, 7];
/// let hashes = values
/// .into_iter()
Expand Down Expand Up @@ -633,8 +633,8 @@ mod test {
use serde::Deserialize;

use super::MemForest;
use crate::accumulator::node_hash::NodeHash;
use crate::accumulator::mem_forest::Node;
use crate::accumulator::node_hash::NodeHash;
use crate::accumulator::proof::Proof;

fn hash_from_u8(value: u8) -> NodeHash {
Expand Down
3 changes: 2 additions & 1 deletion src/accumulator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
//! a lightweight implementation of utreexo that only stores roots. Although the [stump::Stump]
//! only keeps the accumulator's roots, it still trustlessly update this state, not requiring
//! a trusted third party to learn about the current state.
pub mod node_hash;
pub mod mem_forest;
pub mod node_hash;
pub mod pollard;
pub mod proof;
pub mod stump;
pub(super) mod util;
Loading

0 comments on commit 16c754c

Please sign in to comment.