mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-20 19:11:08 +03:00
Define get_data_from_file function on ReadablePMMR trait (#3464)
This commit is contained in:
parent
e7bbda81a0
commit
4c6d1dd4bd
2 changed files with 19 additions and 0 deletions
|
@ -40,6 +40,9 @@ pub trait ReadablePMMR {
|
|||
/// Get the hash from the underlying MMR file (ignores the remove log).
|
||||
fn get_from_file(&self, pos: u64) -> Option<Hash>;
|
||||
|
||||
/// Get the data element at provided position in the MMR (ignores the remove log).
|
||||
fn get_data_from_file(&self, pos: u64) -> Option<Self::Item>;
|
||||
|
||||
/// Total size of the tree, including intermediary nodes and ignoring any pruning.
|
||||
fn unpruned_size(&self) -> u64;
|
||||
|
||||
|
@ -412,6 +415,14 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
fn get_data_from_file(&self, pos: u64) -> Option<Self::Item> {
|
||||
if pos > self.last_pos {
|
||||
None
|
||||
} else {
|
||||
self.backend.get_data_from_file(pos)
|
||||
}
|
||||
}
|
||||
|
||||
fn unpruned_size(&self) -> u64 {
|
||||
self.last_pos
|
||||
}
|
||||
|
|
|
@ -148,6 +148,14 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
fn get_data_from_file(&self, pos: u64) -> Option<Self::Item> {
|
||||
if pos > self.last_pos {
|
||||
None
|
||||
} else {
|
||||
self.backend.get_data_from_file(pos)
|
||||
}
|
||||
}
|
||||
|
||||
fn unpruned_size(&self) -> u64 {
|
||||
self.last_pos
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue