From c1bcbbd654e320d3924abdbb8fd89789331e1a98 Mon Sep 17 00:00:00 2001 From: Joseph Knecht <83087510+JosephKnecht-lab@users.noreply.github.com> Date: Tue, 28 Jan 2025 20:21:04 +0100 Subject: [PATCH] minor changes to checks --- jam/src/blockchain.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/jam/src/blockchain.rs b/jam/src/blockchain.rs index e3687ef..20ab136 100644 --- a/jam/src/blockchain.rs +++ b/jam/src/blockchain.rs @@ -25,10 +25,8 @@ impl Blockchain { } pub fn add_block(&mut self, block: Block) -> Result<(), String> { - // Validate the block if self.validate_block(&block) { - // Update the current slot if block is valid - self.current_slot = block.header.slot; + self.current_slot = block.header.slot; // Update current_slot to the new block's slot self.chain.push(block); Ok(()) } else { @@ -53,11 +51,13 @@ impl Blockchain { } fn validate_slot(&self, slot: u64) -> bool { - // Allow the genesis block (slot 0 or parent hash is genesis hash) + // Allow genesis block (slot 0) if slot == 0 { return true; } - slot >= self.current_slot && slot < self.current_slot + self.epoch_duration + + // Ensure the slot is greater than the current slot + slot > self.current_slot } fn validate_entropy(&self, entropy: &str) -> bool { @@ -74,7 +74,7 @@ impl Blockchain { parent: parent_hash, parent_state_root: "0".repeat(64), extrinsic_hash: extrinsic.calculate_hash(), - slot: self.current_slot, + slot: self.current_slot + 1, // Increment slot for mined block epoch_mark: None, // Placeholder for simplicity tickets_mark: None, // Placeholder for simplicity offenders_mark: vec![],