Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor PMMR read methods into trait #3454

Merged
merged 1 commit into from Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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