keep output and rangeproof mmrs together (#3254)

This commit is contained in:
Antioch Peverell 2020-03-03 15:32:01 +00:00 committed by GitHub
parent b73fc0bb9b
commit 2527006e8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View file

@ -526,16 +526,16 @@ where
{ {
let res: Result<T, Error>; let res: Result<T, Error>;
{ {
let header_pmmr = ReadonlyPMMR::at(&handle.backend, handle.last_pos);
let output_pmmr = let output_pmmr =
ReadonlyPMMR::at(&trees.output_pmmr_h.backend, trees.output_pmmr_h.last_pos); 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 = let rproof_pmmr =
ReadonlyPMMR::at(&trees.rproof_pmmr_h.backend, trees.rproof_pmmr_h.last_pos); ReadonlyPMMR::at(&trees.rproof_pmmr_h.backend, trees.rproof_pmmr_h.last_pos);
// Create a new batch here to pass into the utxo_view. // Create a new batch here to pass into the utxo_view.
// Discard it (rollback) after we finish with the utxo_view. // Discard it (rollback) after we finish with the utxo_view.
let batch = trees.commit_index.batch()?; 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 = inner(&utxo, &batch);
} }
res res
@ -919,8 +919,8 @@ impl<'a> Extension<'a> {
/// and the provided header extension. /// and the provided header extension.
pub fn utxo_view(&'a self, header_ext: &'a HeaderExtension<'a>) -> UTXOView<'a> { pub fn utxo_view(&'a self, header_ext: &'a HeaderExtension<'a>) -> UTXOView<'a> {
UTXOView::new( UTXOView::new(
self.output_pmmr.readonly_pmmr(),
header_ext.pmmr.readonly_pmmr(), header_ext.pmmr.readonly_pmmr(),
self.output_pmmr.readonly_pmmr(),
self.rproof_pmmr.readonly_pmmr(), self.rproof_pmmr.readonly_pmmr(),
) )
} }

View file

@ -26,21 +26,21 @@ use grin_store::pmmr::PMMRBackend;
/// Readonly view of the UTXO set (based on output MMR). /// Readonly view of the UTXO set (based on output MMR).
pub struct UTXOView<'a> { pub struct UTXOView<'a> {
output_pmmr: ReadonlyPMMR<'a, Output, PMMRBackend<Output>>,
header_pmmr: ReadonlyPMMR<'a, BlockHeader, PMMRBackend<BlockHeader>>, header_pmmr: ReadonlyPMMR<'a, BlockHeader, PMMRBackend<BlockHeader>>,
output_pmmr: ReadonlyPMMR<'a, Output, PMMRBackend<Output>>,
rproof_pmmr: ReadonlyPMMR<'a, RangeProof, PMMRBackend<RangeProof>>, rproof_pmmr: ReadonlyPMMR<'a, RangeProof, PMMRBackend<RangeProof>>,
} }
impl<'a> UTXOView<'a> { impl<'a> UTXOView<'a> {
/// Build a new UTXO view. /// Build a new UTXO view.
pub fn new( pub fn new(
output_pmmr: ReadonlyPMMR<'a, Output, PMMRBackend<Output>>,
header_pmmr: ReadonlyPMMR<'a, BlockHeader, PMMRBackend<BlockHeader>>, header_pmmr: ReadonlyPMMR<'a, BlockHeader, PMMRBackend<BlockHeader>>,
output_pmmr: ReadonlyPMMR<'a, Output, PMMRBackend<Output>>,
rproof_pmmr: ReadonlyPMMR<'a, RangeProof, PMMRBackend<RangeProof>>, rproof_pmmr: ReadonlyPMMR<'a, RangeProof, PMMRBackend<RangeProof>>,
) -> UTXOView<'a> { ) -> UTXOView<'a> {
UTXOView { UTXOView {
output_pmmr,
header_pmmr, header_pmmr,
output_pmmr,
rproof_pmmr, rproof_pmmr,
} }
} }