Skip to content

Commit 462ab57

Browse files
Add documentation and PR suggestions.
1 parent 7c64317 commit 462ab57

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

nomos-services/cryptarchia-consensus/src/leadership.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl Leader {
3232
nf_sk: NullifierSecret,
3333
config: Config,
3434
) -> Self {
35-
Leader {
35+
Self {
3636
notes: HashMap::from([(header_id, header_notes)]),
3737
nf_sk,
3838
config,
@@ -44,7 +44,7 @@ impl Leader {
4444
LeaderConfig { notes, nf_sk }: LeaderConfig,
4545
config: Config,
4646
) -> Self {
47-
Leader::new(genesis, notes, nf_sk, config)
47+
Self::new(genesis, notes, nf_sk, config)
4848
}
4949

5050
// Signal that the chain extended with a new header, possibly evolving a leader

nomos-services/cryptarchia-consensus/src/states.rs

+20-5
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,23 @@ use serde::{Deserialize, Serialize};
88

99
use crate::{leadership::Leader, Cryptarchia, CryptarchiaSettings, Error};
1010

11+
/// Indicates that there's stored data so [`Cryptarchia`] should be recovered.
12+
/// However, the number of stored epochs is fewer than
13+
/// [`Config::security_param`](cryptarchia_engine::config::Config).
14+
///
15+
/// As a result, a [`Cryptarchia`](cryptarchia_engine::Cryptarchia) instance
16+
/// must first be built from genesis and then recovered up to the `tip` epoch.
1117
pub struct GenesisRecoveryStrategy {
1218
pub tip: HeaderId,
1319
}
1420

21+
/// Indicates that there's stored data so [`Cryptarchia`] should be recovered,
22+
/// and the number of stored epochs is larger than
23+
/// [`Config::security_param`](cryptarchia_engine::config::Config).
24+
///
25+
/// As a result, a [`Cryptarchia`](cryptarchia_engine::Cryptarchia) instance
26+
/// must first be built from the security state and then recovered up to the
27+
/// `tip` epoch.
1528
pub struct SecurityRecoveryStrategy {
1629
pub tip: HeaderId,
1730
pub security_block_id: HeaderId,
@@ -20,6 +33,8 @@ pub struct SecurityRecoveryStrategy {
2033
}
2134

2235
pub enum CryptarchiaInitialisationStrategy {
36+
/// Indicates that there's no stored data so [`Cryptarchia`] should be built
37+
/// from genesis.
2338
Genesis,
2439
RecoveryFromGenesis(GenesisRecoveryStrategy),
2540
RecoveryFromSecurity(Box<SecurityRecoveryStrategy>),
@@ -51,10 +66,10 @@ impl<TxS, BxS, NetworkAdapterSettings, BlendAdapterSettings>
5166
security_block,
5267
security_ledger_state,
5368
security_leader_notes,
54-
_txs: Default::default(),
55-
_bxs: Default::default(),
56-
_network_adapter_settings: Default::default(),
57-
_blend_adapter_settings: Default::default(),
69+
_txs: PhantomData,
70+
_bxs: PhantomData,
71+
_network_adapter_settings: PhantomData,
72+
_blend_adapter_settings: PhantomData,
5873
}
5974
}
6075

@@ -75,7 +90,7 @@ impl<TxS, BxS, NetworkAdapterSettings, BlendAdapterSettings>
7590
)
7691
}
7792

78-
fn can_recover(&self) -> bool {
93+
const fn can_recover(&self) -> bool {
7994
// This only checks whether tip is defined, as that's a state variable that
8095
// should always exist. Other attributes might not be present.
8196
self.tip.is_some()

0 commit comments

Comments
 (0)