Dump sumtrees state on error

This commit is contained in:
Ignotus Peverell 2017-10-12 19:23:58 +00:00
parent 8e382a7593
commit 2222b28981
No known key found for this signature in database
GPG key ID: 99CD25F39F8F8211
2 changed files with 11 additions and 0 deletions

View file

@ -265,6 +265,7 @@ fn validate_block(b: &Block,
if utxo_root.hash != b.header.utxo_root || rproof_root.hash != b.header.range_proof_root || if utxo_root.hash != b.header.utxo_root || rproof_root.hash != b.header.range_proof_root ||
kernel_root.hash != b.header.kernel_root { kernel_root.hash != b.header.kernel_root {
ext.dump();
return Err(Error::InvalidRoot); return Err(Error::InvalidRoot);
} }

View file

@ -284,6 +284,16 @@ impl<'a> Extension<'a> {
self.rollback = true; self.rollback = true;
} }
/// Dumps the state of the 3 sum trees to stdout for debugging
pub fn dump(&self) {
println!("-- outputs --");
self.output_pmmr.dump();
println!("-- range proofs --");
self.rproof_pmmr.dump();
println!("-- kernels --");
self.kernel_pmmr.dump();
}
// Sizes of the sum trees, used by `extending` on rollback. // Sizes of the sum trees, used by `extending` on rollback.
fn sizes(&self) -> (u64, u64, u64) { fn sizes(&self) -> (u64, u64, u64) {
(self.output_pmmr.unpruned_size(), (self.output_pmmr.unpruned_size(),