Skip to content

Commit

Permalink
refactor: improved error handling and configuration handling
Browse files Browse the repository at this point in the history
- refactor the code to retrieve `slots_per_kes_period` from `config` instead of directly from `genesis_config`
- improve error handling by adding context to the error message
- adjust the calculation of `current_kes_period` to use the updated `slots_per_kes_period` calculation from `config`
  • Loading branch information
falcucci committed Feb 28, 2024
1 parent 583a7f1 commit 2390899
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mithril-common/src/chain_observer/pallas_observer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,11 @@ impl PallasChainObserver {
.map_err(|err| anyhow!(err))
.with_context(|| "PallasChainObserver failed to get genesis config")?;

let slots_per_kes_period = genesis_config[0].slots_per_kes_period as u64;
let config = genesis_config
.first()
.with_context(|| "PallasChainObserver failed to get genesis config")?;

let slots_per_kes_period = config.slots_per_kes_period as u64;
let current_kes_period = chain_point.slot_or_default() / slots_per_kes_period;

Ok(Some(current_kes_period as u32))
Expand Down

0 comments on commit 2390899

Please sign in to comment.