From 1d3bf3c6d887ec0fc188f82e60655d6ab7d0c657 Mon Sep 17 00:00:00 2001 From: Youngjoon Lee <5462944+youngjoon-lee@users.noreply.github.com> Date: Tue, 30 Jan 2024 19:57:54 +0900 Subject: [PATCH] Clarify Cryptarchia slot calcuation (#59) --- cryptarchia/cryptarchia.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cryptarchia/cryptarchia.py b/cryptarchia/cryptarchia.py index 42d9b94..11280c1 100644 --- a/cryptarchia/cryptarchia.py +++ b/cryptarchia/cryptarchia.py @@ -29,7 +29,7 @@ class Slot: absolute_slot: int def from_unix_timestamp_s(config: TimeConfig, timestamp_s: int) -> "Slot": - absolute_slot = timestamp_s // config.slot_duration + absolute_slot = (timestamp_s - config.chain_start_time) // config.slot_duration return Slot(absolute_slot) def epoch(self, config: TimeConfig) -> Epoch: @@ -233,7 +233,7 @@ def chain_density(chain: Chain, slot: Slot) -> int: # Implementation of the fork choice rule as defined in the Ouroboros Genesis paper # k defines the forking depth of chain we accept without more analysis -# s defines the length of time after the fork happened we will inspect for chain density +# s defines the length of time (unit of slots) after the fork happened we will inspect for chain density def maxvalid_bg(local_chain: Chain, forks: List[Chain], k: int, s: int) -> Chain: cmax = local_chain for chain in forks: