force rollback on txhashset extension when validating (#824)

This commit is contained in:
Antioch Peverell 2018-03-20 17:46:29 -04:00 committed by GitHub
parent 4fa9ccc4f7
commit 1d7a7457fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -415,7 +415,16 @@ impl Chain {
pub fn validate(&self) -> Result<(), Error> { pub fn validate(&self) -> Result<(), Error> {
let header = self.store.head_header()?; let header = self.store.head_header()?;
let mut txhashset = self.txhashset.write().unwrap(); 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. /// Check if the input has matured sufficiently for the given block height.