[−][src]Struct grin_store::pmmr::PMMRBackend
PMMR persistent backend implementation. Relies on multiple facilities to handle writing, reading and pruning.
- A main storage file appends Hash instances as they come. This AppendOnlyFile is also backed by a mmap for reads.
- An in-memory backend buffers the latest batch of writes to ensure the PMMR can always read recent values even if they haven't been flushed to disk yet.
- A leaf_set tracks unpruned (unremoved) leaf positions in the MMR..
- A prune_list tracks the positions of pruned (and compacted) roots in the MMR.
Methods
impl<T: PMMRable> PMMRBackend<T>
[src]
pub fn new<P: AsRef<Path>>(
data_dir: P,
prunable: bool,
header: Option<&BlockHeader>
) -> Result<PMMRBackend<T>>
[src]
data_dir: P,
prunable: bool,
header: Option<&BlockHeader>
) -> Result<PMMRBackend<T>>
Instantiates a new PMMR backend. Use the provided dir to store its files.
pub fn unpruned_size(&self) -> u64
[src]
Number of elements in the PMMR stored by this backend. Only produces the fully sync'd size.
pub fn data_size(&self) -> u64
[src]
Number of elements in the underlying stored data. Extremely dependent on pruning and compaction.
pub fn hash_size(&self) -> u64
[src]
Size of the underlying hashed data. Extremely dependent on pruning and compaction.
pub fn sync(&mut self) -> Result<()>
[src]
Syncs all files to disk. A call to sync is required to ensure all the data has been successfully written to disk.
pub fn discard(&mut self)
[src]
Discard the current, non synced state of the backend.
pub fn check_compact(
&mut self,
cutoff_pos: u64,
rewind_rm_pos: &Bitmap
) -> Result<bool>
[src]
&mut self,
cutoff_pos: u64,
rewind_rm_pos: &Bitmap
) -> Result<bool>
Takes the leaf_set at a given cutoff_pos and generates an updated prune_list. Saves the updated prune_list to disk, compacts the hash and data files based on the prune_list and saves both to disk.
A cutoff position limits compaction on recent data. This will be the last position of a particular block to keep things aligned. The block_marker in the db/index for the particular block will have a suitable output_pos. This is used to enforce a horizon after which the local node should have all the data to allow rewinding.
Trait Implementations
impl<T: PMMRable> Backend<T> for PMMRBackend<T>
[src]
fn append(&mut self, data: &T, hashes: Vec<Hash>) -> Result<(), String>
[src]
Append the provided data and hashes to the backend storage. Add the new leaf pos to our leaf_set if this is a prunable MMR.
fn get_from_file(&self, position: u64) -> Option<Hash>
[src]
fn get_data_from_file(&self, position: u64) -> Option<T::E>
[src]
fn get_hash(&self, pos: u64) -> Option<Hash>
[src]
Get the hash at pos. Return None if pos is a leaf and it has been removed (or pruned or compacted).
fn get_data(&self, pos: u64) -> Option<T::E>
[src]
Get the data at pos. Return None if it has been removed or if pos is not a leaf node.
fn leaf_pos_iter(&self) -> Box<dyn Iterator<Item = u64>>
[src]
Returns an iterator over all the leaf positions. for a prunable PMMR this is an iterator over the leaf_set bitmap. For a non-prunable PMMR this is all leaves (this is not yet implemented).
fn rewind(
&mut self,
position: u64,
rewind_rm_pos: &Bitmap
) -> Result<(), String>
[src]
&mut self,
position: u64,
rewind_rm_pos: &Bitmap
) -> Result<(), String>
Rewind the PMMR backend to the given position.
fn remove(&mut self, pos: u64) -> Result<(), String>
[src]
Remove by insertion position.
fn get_data_file_path(&self) -> &Path
[src]
Return data file path
fn release_files(&mut self)
[src]
Release underlying data files
fn snapshot(&self, header: &BlockHeader) -> Result<(), String>
[src]
fn dump_stats(&self)
[src]
Auto Trait Implementations
impl<T> Send for PMMRBackend<T> where
<T as PMMRable>::E: Send,
<T as PMMRable>::E: Send,
impl<T> Sync for PMMRBackend<T> where
<T as PMMRable>::E: Sync,
<T as PMMRable>::E: Sync,
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto 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.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> UnsafeAny for T where
T: Any,
T: Any,
impl<T> Erased for T
impl<T> Same for T
type Output = T
Should always be Self
impl<T> SafeBorrow for T where
T: ?Sized,
T: ?Sized,