fix: regression on state sync (#2289)

* fix the path name of leaf snapshot

* rustfmt

* fix: debug format will add "" on the path name

* rustfmt
This commit is contained in:
Gary Yu
2019-01-05 13:08:49 +08:00
committed by GitHub
parent df5fc7027c
commit 16878dc6a2
2 changed files with 7 additions and 6 deletions
+1 -1
View File
@@ -155,7 +155,7 @@ impl LeafSet {
let mut cp_bitmap = self.bitmap.clone();
cp_bitmap.run_optimize();
let cp_path = self.path.join(header.hash().to_string());
let cp_path = format!("{}.{}", self.path.to_str().unwrap(), header.hash());
let mut file = BufWriter::new(File::create(cp_path)?);
file.write_all(&cp_bitmap.serialize())?;
file.flush()?;
+6 -5
View File
@@ -188,11 +188,12 @@ impl<T: PMMRable> PMMRBackend<T> {
// If we received a rewound "snapshot" leaf_set file move it into
// place so we use it.
if let Some(header) = header {
let _leaf_snapshot_path = (data_dir.join(PMMR_LEAF_FILE).to_string_lossy()
+ header.hash().to_string().as_ref())
.into_owned();
let leaf_snapshot_path = PathBuf::from(_leaf_snapshot_path);
LeafSet::copy_snapshot(&leaf_set_path, &leaf_snapshot_path)?;
let leaf_snapshot_path = format!(
"{}.{}",
data_dir.join(PMMR_LEAF_FILE).to_str().unwrap(),
header.hash()
);
LeafSet::copy_snapshot(&leaf_set_path, &PathBuf::from(leaf_snapshot_path))?;
}
let leaf_set = LeafSet::open(&leaf_set_path)?;