Clarify Cryptarchia slot calcuation (#59)

This commit is contained in:
Youngjoon Lee 2024-01-30 19:57:54 +09:00 committed by GitHub
parent 45c303ef14
commit 1d3bf3c6d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -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: