From 2985561012a30a26cfbbea2da09ee80b3feac1dd Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Mon, 21 Aug 2017 18:31:25 +0900 Subject: [PATCH] detect epoch changes in light client --- ethcore/light/src/client/mod.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ethcore/light/src/client/mod.rs b/ethcore/light/src/client/mod.rs index a41aa551d..c13d6ba91 100644 --- a/ethcore/light/src/client/mod.rs +++ b/ethcore/light/src/client/mod.rs @@ -330,8 +330,14 @@ impl Client { 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 pending = match self.chain.insert(&mut tx, verified_header, None) { + let pending = match self.chain.insert(&mut tx, verified_header, epoch_proof) { Ok(pending) => { good.push(hash); self.report.write().blocks_imported += 1; @@ -344,8 +350,6 @@ impl Client { } }; - // TODO: check epoch end and verify under epoch verifier. - self.db.write_buffered(tx); self.chain.apply_pending(pending); }