Blockchain repair on missing state root (#1646)

* BC locking; Recovery batch

* Missing state root recovery

* Test
This commit is contained in:
Arkadiy Paronyan
2016-07-17 23:03:29 +02:00
committed by Gav Wood
parent 0d2f516ad7
commit dd17c766b8
2 changed files with 86 additions and 26 deletions

View File

@@ -205,6 +205,11 @@ impl Client {
state_db.commit(0, &spec.genesis_header().hash(), None).expect("Error commiting genesis state to state DB");
}
while !chain.block_header(&chain.best_block_hash()).map_or(true, |h| state_db.contains(h.state_root())) {
warn!("State root not found for block #{} ({}), recovering...", chain.best_block_number(), chain.best_block_hash().hex());
chain.rewind();
}
let engine = Arc::new(spec.engine);
let block_queue = BlockQueue::new(config.queue, engine.clone(), message_channel.clone());