From ae8a90be7fd884192bffd237113228c202444145 Mon Sep 17 00:00:00 2001 From: Revertron Date: Thu, 22 Apr 2021 00:32:56 +0200 Subject: [PATCH] Fixed max block constant. --- src/blockchain/chain.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/blockchain/chain.rs b/src/blockchain/chain.rs index 00173fa..b8fba12 100644 --- a/src/blockchain/chain.rs +++ b/src/blockchain/chain.rs @@ -49,6 +49,9 @@ const SQL_GET_ZONES: &str = "SELECT data FROM zones;"; const SQL_GET_OPTIONS: &str = "SELECT * FROM options;"; +/// Max possible block index +const MAX:u64 = i64::MAX as u64; + pub struct Chain { origin: Bytes, last_block: Option, @@ -88,7 +91,7 @@ impl Chain { if block.transaction.is_some() { self.last_full_block = Some(block); } else { - self.last_full_block = self.get_last_full_block(u64::MAX, None); + self.last_full_block = self.get_last_full_block(MAX, None); } } // TODO Add env-var and commandline switches for full check @@ -136,7 +139,7 @@ impl Chain { } } self.last_block = self.load_last_block(); - self.last_full_block = self.get_last_full_block(u64::MAX, None); + self.last_full_block = self.get_last_full_block(MAX, None); info!("Last block after chain check: {:?}", &self.last_block); } @@ -591,7 +594,7 @@ impl Chain { } } let identity_hash = hash_identity(&name, None); - if let Some(last) = self.get_last_full_block(u64::MAX, Some(&pub_key)) { + if let Some(last) = self.get_last_full_block(MAX, Some(&pub_key)) { let new_id = !self.is_id_in_blockchain(&identity_hash, false); let time = last.timestamp + NEW_DOMAINS_INTERVAL - Utc::now().timestamp(); if new_id && time > 0 {