From 8fdc4068cc5b92c7b5d93796618500f11430a8e7 Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Thu, 28 Feb 2019 14:14:17 +0300 Subject: [PATCH] fixed instant finalization of genesis block on light client --- core/client/db/src/light.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/client/db/src/light.rs b/core/client/db/src/light.rs index ae5f011313354..8a3456df69a30 100644 --- a/core/client/db/src/light.rs +++ b/core/client/db/src/light.rs @@ -403,12 +403,13 @@ impl LightBlockchainStorage for LightStorage ); transaction.put(columns::HEADER, &lookup_key, &header.encode()); - if number.is_zero() { - transaction.put(columns::META, meta_keys::FINALIZED_BLOCK, &lookup_key); + let is_genesis = number.is_zero(); + if is_genesis { transaction.put(columns::META, meta_keys::GENESIS_HASH, hash.as_ref()); } let finalized = match leaf_state { + _ if is_genesis => true, NewBlockState::Final => true, _ => false, }; @@ -972,7 +973,7 @@ pub(crate) mod tests { #[test] fn test_leaves_pruned_on_finality() { let db = LightStorage::::new_test(); - let block0 = insert_final_block(&db, None, || default_header(&Default::default(), 0)); + let block0 = insert_block(&db, None, || default_header(&Default::default(), 0)); let block1_a = insert_block(&db, None, || default_header(&block0, 1)); let block1_b = insert_block(&db, None, || header_with_extrinsics_root(&block0, 1, [1; 32].into()));