Skip to content

Commit

Permalink
Change signature of RangeProof
Browse files Browse the repository at this point in the history
We can't specify N since the implementation decides what type to use, so
this is removed from the signature.

The limit should be an option, not a special value of 0
  • Loading branch information
rkuris committed Nov 14, 2023
1 parent 1e8193b commit 57a7774
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
6 changes: 3 additions & 3 deletions firewood/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,12 @@ impl<S: ShaleStore<Node> + Send + Sync> api::DbView for DbRev<S> {
.map_err(|e| api::Error::IO(std::io::Error::new(ErrorKind::Other, e)))
}

async fn range_proof<K: api::KeyType, V, N>(
async fn range_proof<K: api::KeyType, V>(
&self,
_first_key: Option<K>,
_last_key: Option<K>,
_limit: usize,
) -> Result<Option<api::RangeProof<K, V, N>>, api::Error> {
_limit: Option<usize>,
) -> Result<Option<api::RangeProof<Vec<u8>, Vec<u8>>>, api::Error> {
todo!()
}
}
Expand Down
6 changes: 3 additions & 3 deletions firewood/src/db/proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,12 @@ impl api::DbView for Proposal {
.map_err(|e| api::Error::IO(std::io::Error::new(ErrorKind::Other, e)))
}

async fn range_proof<K, V, N>(
async fn range_proof<K, V>(
&self,
_first_key: Option<K>,
_last_key: Option<K>,
_limit: usize,
) -> Result<Option<api::RangeProof<K, V, N>>, api::Error>
_limit: Option<usize>,
) -> Result<Option<api::RangeProof<Vec<u8>, Vec<u8>>>, api::Error>
where
K: api::KeyType,
{
Expand Down
17 changes: 10 additions & 7 deletions firewood/src/v2/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,18 @@ pub enum Error {
InvalidProposal,

#[error("Internal error")]
InternalError(Box<dyn std::error::Error>),
InternalError(Box<dyn std::error::Error + Send>),

#[error("RangeProofError")]
RangeProofError(String),
}

/// 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, V, N> {
pub first_key: Proof<N>,
pub last_key: Proof<N>,
pub struct RangeProof<K, V> {
pub first_key: Proof<Vec<u8>>,
pub last_key: Proof<Vec<u8>>,
pub middle: Vec<(K, V)>,
}

Expand Down Expand Up @@ -152,12 +155,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, N>(
async fn range_proof<K: KeyType, V: Send + Sync>(
&self,
first_key: Option<K>,
last_key: Option<K>,
limit: usize,
) -> Result<Option<RangeProof<K, V, N>>, Error>;
limit: Option<usize>,
) -> Result<Option<RangeProof<Vec<u8>, Vec<u8>>>, Error>;
}

/// A proposal for a new revision of the database.
Expand Down
6 changes: 3 additions & 3 deletions firewood/src/v2/emptydb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ impl DbView for HistoricalImpl {
Ok(None)
}

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

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

0 comments on commit 57a7774

Please sign in to comment.