store pmmr cleanup (#2075)

* introduce DataFile<T> to hide the LEN handling
use slices rather than vec<u8> where possible

* cleanup

* use DataFile<Hash> and not HashFile

* fix core tests
This commit is contained in:
Antioch Peverell
2018-12-05 13:02:24 +00:00
committed by GitHub
parent 45bfe14a21
commit 8d8f533b8e
6 changed files with 83 additions and 90 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ pub trait Backend<T: PMMRable> {
/// Returns the data file path.. this is a bit of a hack now that doesn't
/// sit well with the design, but TxKernels have to be summed and the
/// fastest way to to be able to allow direct access to the file
fn get_data_file_path(&self) -> String;
fn get_data_file_path(&self) -> &str;
/// Also a bit of a hack...
/// Saves a snapshot of the rewound utxo file with the block hash as
+1 -1
View File
@@ -369,7 +369,7 @@ where
}
/// Return the path of the data file (needed to sum kernels efficiently)
pub fn data_file_path(&self) -> String {
pub fn data_file_path(&self) -> &str {
self.backend.get_data_file_path()
}
+1 -1
View File
@@ -291,7 +291,7 @@ pub fn serialize<W: Writeable>(sink: &mut Write, thing: &W) -> Result<(), Error>
/// Utility function to serialize a writeable directly in memory using a
/// Vec<u8>.
pub fn ser_vec<W: Writeable>(thing: &W) -> Result<Vec<u8>, Error> {
let mut vec = Vec::new();
let mut vec = vec![];
serialize(&mut vec, thing)?;
Ok(vec)
}