Skip to content

Commit

Permalink
Add node type to api + proofs (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkuris authored Aug 28, 2023
1 parent 42111f1 commit 0e48de6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions firewood/src/v2/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,17 @@ pub enum Error {
/// A range proof, consisting of a proof of the first key and the last key,
/// and a vector of all key/value pairs
#[derive(Debug)]
pub struct RangeProof<K: KeyType, V: ValueType> {
pub first_key: Proof<V>,
pub last_key: Proof<V>,
pub struct RangeProof<K, V, N> {
pub first_key: Proof<N>,
pub last_key: Proof<N>,
pub middle: Vec<(K, V)>,
}

/// A proof that a single key is present
///
/// The generic N represents the storage for the node data
#[derive(Debug)]
pub struct Proof<N: Send>(pub HashMap<HashKey, N>);
pub struct Proof<N>(pub HashMap<HashKey, N>);

/// The database interface, which includes a type for a static view of
/// the database (the DbView). The most common implementation of the DbView
Expand Down Expand Up @@ -147,12 +147,12 @@ pub trait DbView {
/// * `last_key` - If None, continue to the end of the database
/// * `limit` - The maximum number of keys in the range proof
///
async fn range_proof<K: KeyType, V: ValueType>(
async fn range_proof<K: KeyType, V, N>(
&self,
first_key: Option<K>,
last_key: Option<K>,
limit: usize,
) -> Result<Option<RangeProof<K, V>>, Error>;
) -> Result<Option<RangeProof<K, V, N>>, Error>;
}

/// A proposal for a new revision of the database.
Expand Down
4 changes: 2 additions & 2 deletions firewood/src/v2/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ impl api::DbView for DbView {
todo!()
}

async fn range_proof<K: KeyType, V: ValueType>(
async fn range_proof<K: KeyType, V, N>(
&self,
_first_key: Option<K>,
_last_key: Option<K>,
_limit: usize,
) -> Result<Option<api::RangeProof<K, V>>, api::Error> {
) -> Result<Option<api::RangeProof<K, V, N>>, api::Error> {
todo!()
}
}
4 changes: 2 additions & 2 deletions firewood/src/v2/emptydb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ impl DbView for HistoricalImpl {
Ok(None)
}

async fn range_proof<K: KeyType, V: ValueType>(
async fn range_proof<K: KeyType, V, N>(
&self,
_first_key: Option<K>,
_last_key: Option<K>,
_limit: usize,
) -> Result<Option<RangeProof<K, V>>, Error> {
) -> Result<Option<RangeProof<K, V, N>>, Error> {
Ok(None)
}
}
Expand Down
4 changes: 2 additions & 2 deletions firewood/src/v2/propose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ impl<T: api::DbView + Send + Sync> api::DbView for Proposal<T> {
todo!()
}

async fn range_proof<KT: KeyType, VT: ValueType>(
async fn range_proof<KT: KeyType, VT, NT>(
&self,
_first_key: Option<KT>,
_last_key: Option<KT>,
_limit: usize,
) -> Result<Option<api::RangeProof<KT, VT>>, api::Error> {
) -> Result<Option<api::RangeProof<KT, VT, NT>>, api::Error> {
todo!()
}
}
Expand Down

0 comments on commit 0e48de6

Please sign in to comment.