Skip to content

Commit

Permalink
Add node type to api + proofs
Browse files Browse the repository at this point in the history
Proofs need to how to fetch data from a node they are operating on.
  • Loading branch information
rkuris committed Aug 28, 2023
1 parent 99d97f7 commit 9280fab
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions firewood/src/v2/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ 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: KeyType, V: ValueType, N: AsRef<[u8]> + Send> {
pub first_key: Proof<N>,
pub last_key: Proof<N>,
pub middle: Vec<(K, V)>,
}

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: ValueType, N: AsRef<[u8]> + Send>(
&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: ValueType, N: AsRef<[u8]> + Send>(
&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: ValueType, N: AsRef<[u8]> + Send>(
&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: ValueType, NT: AsRef<[u8]> + Send>(
&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 9280fab

Please sign in to comment.