From 3309959139cd8308367e83cf80d3639866beb268 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 2 Mar 2016 12:57:34 +0100 Subject: [PATCH] Additional check to ancient enactments. --- ethcore/src/client.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ethcore/src/client.rs b/ethcore/src/client.rs index f2894decb..803f5c9db 100644 --- a/ethcore/src/client.rs +++ b/ethcore/src/client.rs @@ -257,6 +257,14 @@ impl Client { let engine = self.engine.deref().deref(); let header = &block.header; + // Check the block isn't so old we won't be able to enact it. + let best_block_number = self.chain.read().unwrap().best_block_number(); + debug!("Best: {}, importing: {}", best_block_number, header.number()); + if header.number() <= best_block_number - HISTORY { + warn!(target: "client", "Block import failed for #{} ({})\nBlock is ancient (current best block: #{}).", header.number(), header.hash(), best_block_number); + return Err(()); + } + // Verify Block Family let verify_family_result = verify_block_family(&header, &block.bytes, engine, self.chain.read().unwrap().deref()); if let Err(e) = verify_family_result {