@@ -66,9 +66,6 @@ pub struct Configuration {
66
66
/// Protocol parameters
67
67
pub protocol_parameters : ProtocolParameters ,
68
68
69
- /// Snapshots manifest location
70
- pub url_snapshot_manifest : String ,
71
-
72
69
/// Type of snapshot uploader to use
73
70
pub snapshot_uploader_type : SnapshotUploaderType ,
74
71
@@ -97,7 +94,10 @@ pub struct Configuration {
97
94
pub genesis_verification_key : HexEncodedGenesisVerificationKey ,
98
95
99
96
/// Should the immutable cache be reset or not
100
- pub reset_digests_cache : Option < bool > ,
97
+ pub reset_digests_cache : bool ,
98
+
99
+ /// Use the digest caching strategy
100
+ pub disable_digests_cache : bool ,
101
101
102
102
/// Max number of records in stores.
103
103
/// When new records are added, oldest records are automatically deleted so
@@ -122,8 +122,9 @@ pub enum SnapshotUploaderType {
122
122
Local ,
123
123
}
124
124
125
- impl Default for Configuration {
126
- fn default ( ) -> Self {
125
+ impl Configuration {
126
+ /// Create a sample configuration mainly for tests
127
+ pub fn new_sample ( ) -> Self {
127
128
let genesis_verification_key = ProtocolGenesisSigner :: create_deterministic_genesis_signer ( )
128
129
. create_genesis_verifier ( )
129
130
. to_verification_key ( ) ;
@@ -139,8 +140,6 @@ impl Default for Configuration {
139
140
m : 100 ,
140
141
phi_f : 0.95 ,
141
142
} ,
142
- url_snapshot_manifest : "https://storage.googleapis.com/cardano-testnet/snapshots.json"
143
- . to_string ( ) ,
144
143
snapshot_uploader_type : SnapshotUploaderType :: Local ,
145
144
snapshot_bucket_name : None ,
146
145
server_ip : "0.0.0.0" . to_string ( ) ,
@@ -150,15 +149,14 @@ impl Default for Configuration {
150
149
snapshot_directory : PathBuf :: new ( ) ,
151
150
data_stores_directory : PathBuf :: new ( ) ,
152
151
genesis_verification_key : key_encode_hex ( genesis_verification_key) . unwrap ( ) ,
153
- reset_digests_cache : Some ( false ) ,
152
+ reset_digests_cache : false ,
153
+ disable_digests_cache : false ,
154
154
store_retention_limit : None ,
155
155
era_reader_adapter_type : EraReaderAdapterType :: Bootstrap ,
156
156
era_reader_adapter_params : None ,
157
157
}
158
158
}
159
- }
160
159
161
- impl Configuration {
162
160
/// Build the server URL from configuration.
163
161
pub fn get_server_url ( & self ) -> String {
164
162
format ! ( "http://{}:{}/" , self . server_ip, self . server_port)
@@ -204,6 +202,9 @@ impl Configuration {
204
202
/// Default configuration with all the default values for configurations.
205
203
#[ derive( Debug , Clone ) ]
206
204
pub struct DefaultConfiguration {
205
+ /// Execution environment
206
+ pub environment : ExecutionEnvironment ,
207
+
207
208
/// Server listening IP
208
209
pub server_ip : String ,
209
210
@@ -227,11 +228,15 @@ pub struct DefaultConfiguration {
227
228
228
229
/// ImmutableDigesterCacheProvider default setting
229
230
pub reset_digests_cache : String ,
231
+
232
+ /// ImmutableDigesterCacheProvider default setting
233
+ pub disable_digests_cache : String ,
230
234
}
231
235
232
236
impl Default for DefaultConfiguration {
233
237
fn default ( ) -> Self {
234
238
Self {
239
+ environment : ExecutionEnvironment :: Production ,
235
240
server_ip : "0.0.0.0" . to_string ( ) ,
236
241
server_port : "8080" . to_string ( ) ,
237
242
db_directory : "/db" . to_string ( ) ,
@@ -240,6 +245,16 @@ impl Default for DefaultConfiguration {
240
245
snapshot_uploader_type : "gcp" . to_string ( ) ,
241
246
era_reader_adapter_type : "bootstrap" . to_string ( ) ,
242
247
reset_digests_cache : "false" . to_string ( ) ,
248
+ disable_digests_cache : "false" . to_string ( ) ,
249
+ }
250
+ }
251
+ }
252
+
253
+ impl From < ExecutionEnvironment > for ValueKind {
254
+ fn from ( value : ExecutionEnvironment ) -> Self {
255
+ match value {
256
+ ExecutionEnvironment :: Production => ValueKind :: String ( "Production" . to_string ( ) ) ,
257
+ ExecutionEnvironment :: Test => ValueKind :: String ( "Test" . to_string ( ) ) ,
243
258
}
244
259
}
245
260
}
@@ -253,6 +268,10 @@ impl Source for DefaultConfiguration {
253
268
let mut result = Map :: new ( ) ;
254
269
let namespace = "default configuration" . to_string ( ) ;
255
270
let myself = self . clone ( ) ;
271
+ result. insert (
272
+ "environment" . to_string ( ) ,
273
+ Value :: new ( Some ( & namespace) , ValueKind :: from ( myself. environment ) ) ,
274
+ ) ;
256
275
result. insert (
257
276
"server_ip" . to_string ( ) ,
258
277
Value :: new ( Some ( & namespace) , ValueKind :: from ( myself. server_ip ) ) ,
@@ -297,6 +316,13 @@ impl Source for DefaultConfiguration {
297
316
ValueKind :: from ( myself. reset_digests_cache ) ,
298
317
) ,
299
318
) ;
319
+ result. insert (
320
+ "disable_digests_cache" . to_string ( ) ,
321
+ Value :: new (
322
+ Some ( & namespace) ,
323
+ ValueKind :: from ( myself. disable_digests_cache ) ,
324
+ ) ,
325
+ ) ;
300
326
301
327
Ok ( result)
302
328
}
0 commit comments