detect epoch changes in light client
This commit is contained in:
parent
6ab0fc4e14
commit
2985561012
@ -330,8 +330,14 @@ impl<T: ChainDataFetcher> Client<T> {
|
|||||||
The node may not be able to synchronize further.", e);
|
The node may not be able to synchronize further.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let epoch_proof = self.engine.is_epoch_end(
|
||||||
|
&verified_header,
|
||||||
|
&|h| self.chain.block_header(BlockId::Hash(h)).map(|hdr| hdr.decode()),
|
||||||
|
&|h| self.chain.pending_transition(h),
|
||||||
|
);
|
||||||
|
|
||||||
let mut tx = self.db.transaction();
|
let mut tx = self.db.transaction();
|
||||||
let pending = match self.chain.insert(&mut tx, verified_header, None) {
|
let pending = match self.chain.insert(&mut tx, verified_header, epoch_proof) {
|
||||||
Ok(pending) => {
|
Ok(pending) => {
|
||||||
good.push(hash);
|
good.push(hash);
|
||||||
self.report.write().blocks_imported += 1;
|
self.report.write().blocks_imported += 1;
|
||||||
@ -344,8 +350,6 @@ impl<T: ChainDataFetcher> Client<T> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: check epoch end and verify under epoch verifier.
|
|
||||||
|
|
||||||
self.db.write_buffered(tx);
|
self.db.write_buffered(tx);
|
||||||
self.chain.apply_pending(pending);
|
self.chain.apply_pending(pending);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user