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

keep output and rangeproof mmrs together #3254

Merged
merged 1 commit into from
Mar 3, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions chain/src/txhashset/txhashset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,16 +526,16 @@ where
{
let res: Result<T, Error>;
{
let header_pmmr = ReadonlyPMMR::at(&handle.backend, handle.last_pos);
let output_pmmr =
ReadonlyPMMR::at(&trees.output_pmmr_h.backend, trees.output_pmmr_h.last_pos);
let header_pmmr = ReadonlyPMMR::at(&handle.backend, handle.last_pos);
let rproof_pmmr =
ReadonlyPMMR::at(&trees.rproof_pmmr_h.backend, trees.rproof_pmmr_h.last_pos);

// Create a new batch here to pass into the utxo_view.
// Discard it (rollback) after we finish with the utxo_view.
let batch = trees.commit_index.batch()?;
let utxo = UTXOView::new(output_pmmr, header_pmmr, rproof_pmmr);
let utxo = UTXOView::new(header_pmmr, output_pmmr, rproof_pmmr);
res = inner(&utxo, &batch);
}
res
Expand Down Expand Up @@ -919,8 +919,8 @@ impl<'a> Extension<'a> {
/// and the provided header extension.
pub fn utxo_view(&'a self, header_ext: &'a HeaderExtension<'a>) -> UTXOView<'a> {
UTXOView::new(
self.output_pmmr.readonly_pmmr(),
header_ext.pmmr.readonly_pmmr(),
self.output_pmmr.readonly_pmmr(),
self.rproof_pmmr.readonly_pmmr(),
)
}
Expand Down
6 changes: 3 additions & 3 deletions chain/src/txhashset/utxo_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ use grin_store::pmmr::PMMRBackend;

/// Readonly view of the UTXO set (based on output MMR).
pub struct UTXOView<'a> {
output_pmmr: ReadonlyPMMR<'a, Output, PMMRBackend<Output>>,
header_pmmr: ReadonlyPMMR<'a, BlockHeader, PMMRBackend<BlockHeader>>,
output_pmmr: ReadonlyPMMR<'a, Output, PMMRBackend<Output>>,
rproof_pmmr: ReadonlyPMMR<'a, RangeProof, PMMRBackend<RangeProof>>,
}

impl<'a> UTXOView<'a> {
/// Build a new UTXO view.
pub fn new(
output_pmmr: ReadonlyPMMR<'a, Output, PMMRBackend<Output>>,
header_pmmr: ReadonlyPMMR<'a, BlockHeader, PMMRBackend<BlockHeader>>,
output_pmmr: ReadonlyPMMR<'a, Output, PMMRBackend<Output>>,
rproof_pmmr: ReadonlyPMMR<'a, RangeProof, PMMRBackend<RangeProof>>,
) -> UTXOView<'a> {
UTXOView {
output_pmmr,
header_pmmr,
output_pmmr,
rproof_pmmr,
}
}
Expand Down