From 1d7a7457fc0af7db4570d5d88f6eed138df82fa2 Mon Sep 17 00:00:00 2001 From: Antioch Peverell <30642645+antiochp@users.noreply.github.com> Date: Tue, 20 Mar 2018 17:46:29 -0400 Subject: [PATCH] force rollback on txhashset extension when validating (#824) --- chain/src/chain.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/chain/src/chain.rs b/chain/src/chain.rs index 9d4280e2..1c8d4491 100644 --- a/chain/src/chain.rs +++ b/chain/src/chain.rs @@ -415,7 +415,16 @@ impl Chain { pub fn validate(&self) -> Result<(), Error> { let header = self.store.head_header()?; let mut txhashset = self.txhashset.write().unwrap(); - txhashset::extending(&mut txhashset, |extension| extension.validate(&header)) + + // Now create an extension from the txhashset and validate + // against the latest block header. + // We will rewind the extension internally to the pos for + // the block header to ensure the view is consistent. + // Force rollback first as this is a "read-only" extension. + txhashset::extending(&mut txhashset, |extension| { + extension.force_rollback(); + extension.validate(&header) + }) } /// Check if the input has matured sufficiently for the given block height.