Fix/serializing hash (#2355)

* Remvoe 3 dots from hash formatting
* Move 3 dots to the TUI
* Add backwards check
* Add triple dot to check_and_remove_files + typo
This commit is contained in:
Ignotus Peverell 2019-01-12 13:07:03 -08:00 committed by GitHub
commit e3a1c2c6b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 5 deletions

View file

@ -1456,7 +1456,7 @@ fn check_and_remove_files(txhashset_path: &PathBuf, header: &BlockHeader) -> Res
}
// Then compare the files found in the subdirectories
let pmmr_files_expected: HashSet<_> = PMMR_FILES
let mut pmmr_files_expected: HashSet<_> = PMMR_FILES
.iter()
.cloned()
.map(|s| {
@ -1467,6 +1467,8 @@ fn check_and_remove_files(txhashset_path: &PathBuf, header: &BlockHeader) -> Res
}
})
.collect();
// prevent checker from deleting 3 dot file, could be removed after mainnet
pmmr_files_expected.insert(format!("pmmr_leaf.bin.{}...", header.hash()));
let subdirectories = fs::read_dir(txhashset_path)?;
for subdirectory in subdirectories {

View file

@ -41,7 +41,7 @@ impl fmt::Debug for Hash {
let hash_hex = self.to_hex();
const NUM_SHOW: usize = 12;
write!(f, "{}...", &hash_hex[..NUM_SHOW])
write!(f, "{}", &hash_hex[..NUM_SHOW])
}
}

View file

@ -241,7 +241,7 @@ impl TUIStatusListener for TUIStatusView {
t.set_content(stats.peer_count.to_string());
});
c.call_on_id("tip_hash", |t: &mut TextView| {
t.set_content(stats.head.last_block_h.to_string());
t.set_content(stats.head.last_block_h.to_string() + "...");
});
c.call_on_id("chain_height", |t: &mut TextView| {
t.set_content(stats.head.height.to_string());
@ -250,7 +250,7 @@ impl TUIStatusListener for TUIStatusView {
t.set_content(stats.head.total_difficulty.to_string());
});
c.call_on_id("basic_header_tip_hash", |t: &mut TextView| {
t.set_content(stats.header_head.last_block_h.to_string());
t.set_content(stats.header_head.last_block_h.to_string() + "...");
});
c.call_on_id("basic_header_chain_height", |t: &mut TextView| {
t.set_content(stats.header_head.height.to_string());

View file

@ -193,7 +193,13 @@ impl<T: PMMRable> PMMRBackend<T> {
data_dir.join(PMMR_LEAF_FILE).to_str().unwrap(),
header.hash()
);
LeafSet::copy_snapshot(&leaf_set_path, &PathBuf::from(leaf_snapshot_path))?;
// Check for a ... (3 dot) ending version of the file - could probably be removed after mainnet
let compatible_snapshot_path = PathBuf::from(leaf_snapshot_path.clone() + "...");
if compatible_snapshot_path.exists() {
LeafSet::copy_snapshot(&leaf_set_path, &compatible_snapshot_path)?;
} else {
LeafSet::copy_snapshot(&leaf_set_path, &PathBuf::from(leaf_snapshot_path))?;
}
}
let leaf_set = LeafSet::open(&leaf_set_path)?;