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
+10 -1
View File
@@ -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.