only load ancestry from chain closure in engine

This commit is contained in:
Robert Habermeier 2017-08-24 16:29:31 +02:00
parent b953f9b66a
commit c79ecee094
2 changed files with 12 additions and 7 deletions

View File

@ -411,8 +411,8 @@ impl HeaderChain {
self.live_epoch_proofs.write().insert(hash, transition);
}
let raw = ::rlp::encode(&header);
transaction.put(self.col, &hash[..], &*raw);
let raw = header.encoded().into_inner();
transaction.put_vec(self.col, &hash[..], raw);
let (best_num, is_new_best) = {
let cur_best = self.best_block.read();

View File

@ -745,13 +745,18 @@ impl Engine for AuthorityRound {
{
if let Ok(finalized) = epoch_manager.finality_checker.push_hash(chain_head.hash(), *chain_head.author()) {
let mut finalized = finalized.into_iter();
while let Some(hash) = finalized.next() {
if let Some(pending) = transition_store(hash) {
let finality_proof = ::std::iter::once(hash)
while let Some(finalized_hash) = finalized.next() {
if let Some(pending) = transition_store(finalized_hash) {
let finality_proof = ::std::iter::once(finalized_hash)
.chain(finalized)
.chain(epoch_manager.finality_checker.unfinalized_hashes())
.map(|hash| chain(hash)
.expect("these headers fetched before when constructing finality checker; qed"))
.map(|h| if h == chain_head.hash() {
// chain closure only stores ancestry, but the chain head is also
// unfinalized.
chain_head.clone()
} else {
chain(h).expect("these headers fetched before when constructing finality checker; qed")
})
.collect::<Vec<Header>>();
// this gives us the block number for `hash`, assuming it's ancestry.