@@ -8,10 +8,23 @@ use serde::{Deserialize, Serialize};
8
8
9
9
use crate :: { leadership:: Leader , Cryptarchia , CryptarchiaSettings , Error } ;
10
10
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.
11
17
pub struct GenesisRecoveryStrategy {
12
18
pub tip : HeaderId ,
13
19
}
14
20
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.
15
28
pub struct SecurityRecoveryStrategy {
16
29
pub tip : HeaderId ,
17
30
pub security_block_id : HeaderId ,
@@ -20,6 +33,8 @@ pub struct SecurityRecoveryStrategy {
20
33
}
21
34
22
35
pub enum CryptarchiaInitialisationStrategy {
36
+ /// Indicates that there's no stored data so [`Cryptarchia`] should be built
37
+ /// from genesis.
23
38
Genesis ,
24
39
RecoveryFromGenesis ( GenesisRecoveryStrategy ) ,
25
40
RecoveryFromSecurity ( Box < SecurityRecoveryStrategy > ) ,
@@ -51,10 +66,10 @@ impl<TxS, BxS, NetworkAdapterSettings, BlendAdapterSettings>
51
66
security_block,
52
67
security_ledger_state,
53
68
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 ,
58
73
}
59
74
}
60
75
@@ -75,7 +90,7 @@ impl<TxS, BxS, NetworkAdapterSettings, BlendAdapterSettings>
75
90
)
76
91
}
77
92
78
- fn can_recover ( & self ) -> bool {
93
+ const fn can_recover ( & self ) -> bool {
79
94
// This only checks whether tip is defined, as that's a state variable that
80
95
// should always exist. Other attributes might not be present.
81
96
self . tip . is_some ( )
0 commit comments