1
1
use anyhow:: Context ;
2
2
use config:: { ConfigError , Map , Source , Value } ;
3
+ #[ cfg( feature = "future_dmq" ) ]
4
+ use mithril_dmq:: DmqNetwork ;
3
5
use mithril_doc:: { Documenter , DocumenterDefault , StructDoc } ;
4
6
use serde:: { Deserialize , Serialize } ;
5
7
use std:: { path:: PathBuf , sync:: Arc } ;
@@ -53,11 +55,16 @@ pub struct Configuration {
53
55
#[ example = "`mainnet` or `preprod` or `devnet`" ]
54
56
pub network : String ,
55
57
56
- /// Cardano Network Magic number
58
+ /// Cardano network magic number
57
59
/// useful for TestNet & DevNet
58
60
#[ example = "`1097911063` or `42`" ]
59
61
pub network_magic : Option < u64 > ,
60
62
63
+ /// DMQ network magic number
64
+ /// useful for TestNet & DevNet
65
+ #[ example = "`1097911063` or `42`" ]
66
+ pub dmq_network_magic : Option < u64 > ,
67
+
61
68
/// Also known as `k`, it defines the number of blocks that are required for the blockchain to
62
69
/// be considered final, preventing any further rollback `[default: 2160]`.
63
70
pub network_security_parameter : BlockNumber ,
@@ -164,6 +171,7 @@ impl Configuration {
164
171
db_directory : PathBuf :: new ( ) ,
165
172
network : "devnet" . to_string ( ) ,
166
173
network_magic : Some ( 42 ) ,
174
+ dmq_network_magic : Some ( 3141592 ) ,
167
175
network_security_parameter : BlockNumber ( 2160 ) ,
168
176
preload_security_parameter : BlockNumber ( 30 ) ,
169
177
party_id : Some ( party_id) ,
@@ -195,7 +203,7 @@ impl Configuration {
195
203
}
196
204
}
197
205
198
- /// Return the CardanoNetwork value from the configuration.
206
+ /// Return the Cardano network value from the configuration.
199
207
pub fn get_network ( & self ) -> StdResult < CardanoNetwork > {
200
208
CardanoNetwork :: from_code ( self . network . clone ( ) , self . network_magic ) . with_context ( || {
201
209
format ! (
@@ -205,6 +213,17 @@ impl Configuration {
205
213
} )
206
214
}
207
215
216
+ /// Return the DMQ network value from the configuration.
217
+ #[ cfg( feature = "future_dmq" ) ]
218
+ pub fn get_dmq_network ( & self ) -> StdResult < DmqNetwork > {
219
+ DmqNetwork :: from_code ( self . network . clone ( ) , self . dmq_network_magic ) . with_context ( || {
220
+ format ! (
221
+ "Could not read DMQ Network '{}' from configuration." ,
222
+ & self . network
223
+ )
224
+ } )
225
+ }
226
+
208
227
/// Create the SQL store directory if not exist and return the path of the
209
228
/// SQLite3 file.
210
229
pub fn get_sqlite_file ( & self , sqlite_file_name : & str ) -> StdResult < PathBuf > {
0 commit comments