From 4436cb6fa6a9f6242bcb7cca4458277206ab7387 Mon Sep 17 00:00:00 2001 From: antiochp <30642645+antiochp@users.noreply.github.com> Date: Thu, 29 Aug 2019 13:06:48 +0100 Subject: [PATCH] roll the "fix invalid root" changes into this PR --- chain/src/txhashset/txhashset.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/chain/src/txhashset/txhashset.rs b/chain/src/txhashset/txhashset.rs index 2a881b1651..99cef2a55d 100644 --- a/chain/src/txhashset/txhashset.rs +++ b/chain/src/txhashset/txhashset.rs @@ -300,15 +300,14 @@ where let commit_index = trees.commit_index.clone(); let batch = commit_index.batch()?; - // We want to use the current head of the most work chain unless - // we explicitly rewind the extension. - let head = batch.head()?; - trace!("Starting new txhashset (readonly) extension."); + let head = batch.head()?; + let header_head = batch.header_head()?; + let res = { let header_pmmr = PMMR::at(&mut handle.backend, handle.last_pos); - let mut header_extension = HeaderExtension::new(header_pmmr, &batch, head.clone()); + let mut header_extension = HeaderExtension::new(header_pmmr, &batch, header_head); let mut extension = Extension::new(trees, &batch, head); let mut extension_pair = ExtensionPair { header_extension: &mut header_extension, @@ -399,9 +398,8 @@ where let res: Result; let rollback: bool; - // We want to use the current head of the most work chain unless - // we explicitly rewind the extension. let head = batch.head()?; + let header_head = batch.header_head()?; // create a child transaction so if the state is rolled back by itself, all // index saving can be undone @@ -410,7 +408,7 @@ where trace!("Starting new txhashset extension."); let pmmr = PMMR::at(&mut header_pmmr.backend, header_pmmr.last_pos); - let mut header_extension = HeaderExtension::new(pmmr, &child_batch, head.clone()); + let mut header_extension = HeaderExtension::new(pmmr, &child_batch, header_head); let mut extension = Extension::new(trees, &child_batch, head); let mut extension_pair = ExtensionPair { header_extension: &mut header_extension,