[−][src]Struct merk::Merk
A handle to a Merkle key/value store backed by RocksDB.
Implementations
impl Merk
[src]
pub fn open<P: AsRef<Path>>(path: P) -> Result<Merk>
[src]
Opens a store with the specified file path. If no store exists at that path, one will be created.
pub fn open_opt<P>(path: P, db_opts: Options) -> Result<Merk> where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
Opens a store with the specified file path and the given options. If no store exists at that path, one will be created.
pub fn default_db_opts() -> Options
[src]
pub fn get_aux(&self, key: &[u8]) -> Result<Option<Vec<u8>>>
[src]
Gets an auxiliary value.
pub fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>>
[src]
Gets a value for the given key. If the key is not found, None
is
returned.
Note that this is essentially the same as a normal RocksDB get
, so
should be a fast operation and has almost no tree overhead.
pub fn root_hash(&self) -> Hash
[src]
Returns the root hash of the tree (a digest for the entire store which proofs can be checked against). If the tree is empty, returns the null hash (zero-filled).
pub fn apply(&mut self, batch: &Batch, aux: &Batch) -> Result<()>
[src]
Applies a batch of operations (puts and deletes) to the tree.
This will fail if the keys in batch
are not sorted and unique. This
check creates some overhead, so if you are sure your batch is sorted and
unique you can use the unsafe apply_unchecked
for a small performance
gain.
Example
use merk::Op; let batch = &[ (vec![1, 2, 3], Op::Put(vec![4, 5, 6])), // puts value [4,5,6] to key [1,2,3] (vec![4, 5, 6], Op::Delete) // deletes key [4,5,6] ]; store.apply(batch, &[]).unwrap();
pub unsafe fn apply_unchecked(
&mut self,
batch: &Batch,
aux: &Batch
) -> Result<()>
[src]
&mut self,
batch: &Batch,
aux: &Batch
) -> Result<()>
Applies a batch of operations (puts and deletes) to the tree.
This is unsafe because the keys in batch
must be sorted and unique -
if they are not, there will be undefined behavior. For a safe version of
this method which checks to ensure the batch is sorted and unique, see
apply
.
Example
use merk::Op; let batch = &[ (vec![1, 2, 3], Op::Put(vec![4, 5, 6])), // puts value [4,5,6] to key [1,2,3] (vec![4, 5, 6], Op::Delete) // deletes key [4,5,6] ]; unsafe { store.apply_unchecked(batch, &[]).unwrap() };
pub fn destroy(self) -> Result<()>
[src]
Closes the store and deletes all data from disk.
pub fn prove(&self, query: &[Vec<u8>]) -> Result<Vec<u8>>
[src]
Creates a Merkle proof for the list of queried keys. For each key in the query, if the key is found in the store then the value will be proven to be in the tree. For each key in the query that does not exist in the tree, its absence will be proven by including boundary keys.
The proof returned is in an encoded format which can be verified with
merk::verify
.
This will fail if the keys in query
are not sorted and unique. This
check adds some overhead, so if you are sure your batch is sorted and
unique you can use the unsafe prove_unchecked
for a small performance
gain.
pub unsafe fn prove_unchecked(&self, query: &[Vec<u8>]) -> Result<Vec<u8>>
[src]
Creates a Merkle proof for the list of queried keys. For each key in the query, if the key is found in the store then the value will be proven to be in the tree. For each key in the query that does not exist in the tree, its absence will be proven by including boundary keys.
The proof returned is in an encoded format which can be verified with
merk::verify
.
This is unsafe because the keys in query
must be sorted and unique -
if they are not, there will be undefined behavior. For a safe version of
this method which checks to ensure the batch is sorted and unique, see
prove
.
pub fn flush(&self) -> Result<()>
[src]
pub fn commit(
&mut self,
deleted_keys: LinkedList<Vec<u8>>,
aux: &Batch
) -> Result<()>
[src]
&mut self,
deleted_keys: LinkedList<Vec<u8>>,
aux: &Batch
) -> Result<()>
pub fn walk<T>(
&self,
f: impl FnOnce(Option<RefWalker<'_, MerkSource<'_>>>) -> T
) -> T
[src]
&self,
f: impl FnOnce(Option<RefWalker<'_, MerkSource<'_>>>) -> T
) -> T
pub fn raw_iter(&self) -> DBRawIterator<'_>
[src]
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Merk
impl Send for Merk
impl !Sync for Merk
impl Terminated for Merk
impl Unpin for Merk
impl UnwindSafe for Merk
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,