Refactor rewind single header (#1390)

* refactor txhashset to only take a single header
no need to pass in current head_header each time

* rustfmt

* fix bug introduced in rewind with LMDB

* rustfmt

* add some comments
This commit is contained in:
Antioch Peverell
2018-08-20 20:34:12 +01:00
committed by GitHub
parent 8440aad7ea
commit bb7bc2c4f2
9 changed files with 118 additions and 127 deletions
+1 -2
View File
@@ -83,11 +83,10 @@ impl BlockChain for ChainAdapter {
.store
.get_block_header(&block_hash)
.map_err(|_| PoolError::Other(format!("failed to get header")))?;
let head_header = self.chain_head()?;
let mut txhashset = self.txhashset.write().unwrap();
let res = txhashset::extending_readonly(&mut txhashset, |extension| {
extension.rewind(&header, &head_header)?;
extension.rewind(&header)?;
let valid_txs = extension.validate_raw_txs(txs, pre_tx)?;
Ok(valid_txs)
}).map_err(|e| PoolError::Other(format!("Error: test chain adapter: {:?}", e)))?;