Skip to content

Commit

Permalink
Refactor PMMR read methods into trait (#3454)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspervdm committed Sep 29, 2020
1 parent defc714 commit 0aec8b5
Show file tree
Hide file tree
Showing 9 changed files with 255 additions and 250 deletions.
6 changes: 4 additions & 2 deletions chain/src/txhashset/bitmap_accumulator.rs
Expand Up @@ -19,7 +19,7 @@ use bit_vec::BitVec;
use croaring::Bitmap;

use crate::core::core::hash::{DefaultHashable, Hash};
use crate::core::core::pmmr::{self, ReadonlyPMMR, VecBackend, PMMR};
use crate::core::core::pmmr::{self, ReadablePMMR, ReadonlyPMMR, VecBackend, PMMR};
use crate::core::ser::{self, PMMRable, Readable, Reader, Writeable, Writer};
use crate::error::{Error, ErrorKind};

Expand Down Expand Up @@ -176,7 +176,9 @@ impl BitmapAccumulator {

/// The root hash of the bitmap accumulator MMR.
pub fn root(&self) -> Hash {
ReadonlyPMMR::at(&self.backend, self.backend.size()).root()
ReadonlyPMMR::at(&self.backend, self.backend.size())
.root()
.expect("no root, invalid tree")
}
}

Expand Down
8 changes: 4 additions & 4 deletions chain/src/txhashset/txhashset.rs
Expand Up @@ -19,7 +19,7 @@ use crate::core::consensus::WEEK_HEIGHT;
use crate::core::core::committed::Committed;
use crate::core::core::hash::{Hash, Hashed};
use crate::core::core::merkle_proof::MerkleProof;
use crate::core::core::pmmr::{self, Backend, ReadonlyPMMR, RewindablePMMR, PMMR};
use crate::core::core::pmmr::{self, Backend, ReadablePMMR, ReadonlyPMMR, RewindablePMMR, PMMR};
use crate::core::core::{Block, BlockHeader, KernelFeatures, Output, OutputIdentifier, TxKernel};
use crate::core::global;
use crate::core::ser::{PMMRable, ProtocolVersion};
Expand Down Expand Up @@ -369,11 +369,11 @@ impl TxHashSet {

TxHashSetRoots {
output_roots: OutputRoots {
pmmr_root: output_pmmr.root(),
pmmr_root: output_pmmr.root().expect("no root, invalid tree"),
bitmap_root: self.bitmap_accumulator.root(),
},
rproof_root: rproof_pmmr.root(),
kernel_root: kernel_pmmr.root(),
rproof_root: rproof_pmmr.root().expect("no root, invalid tree"),
kernel_root: kernel_pmmr.root().expect("no root, invalid tree"),
}
}

Expand Down
2 changes: 1 addition & 1 deletion chain/src/txhashset/utxo_view.rs
Expand Up @@ -15,7 +15,7 @@
//! Lightweight readonly view into output MMR for convenience.

use crate::core::core::hash::{Hash, Hashed};
use crate::core::core::pmmr::{self, ReadonlyPMMR};
use crate::core::core::pmmr::{self, ReadablePMMR, ReadonlyPMMR};
use crate::core::core::{Block, BlockHeader, Inputs, Output, OutputIdentifier, Transaction};
use crate::core::global;
use crate::error::{Error, ErrorKind};
Expand Down

0 comments on commit 0aec8b5

Please sign in to comment.