11use anyhow:: Context ;
22use config:: { ConfigError , Map , Source , Value } ;
3+ #[ cfg( feature = "future_dmq" ) ]
4+ use mithril_dmq:: DmqNetwork ;
35use mithril_doc:: { Documenter , DocumenterDefault , StructDoc } ;
46use serde:: { Deserialize , Serialize } ;
57use std:: { path:: PathBuf , sync:: Arc } ;
@@ -53,11 +55,16 @@ pub struct Configuration {
5355 #[ example = "`mainnet` or `preprod` or `devnet`" ]
5456 pub network : String ,
5557
56- /// Cardano Network Magic number
58+ /// Cardano network magic number
5759 /// useful for TestNet & DevNet
5860 #[ example = "`1097911063` or `42`" ]
5961 pub network_magic : Option < u64 > ,
6062
63+ /// DMQ network magic number
64+ /// useful for TestNet & DevNet
65+ #[ example = "`1097911063` or `42`" ]
66+ pub dmq_network_magic : Option < u64 > ,
67+
6168 /// Also known as `k`, it defines the number of blocks that are required for the blockchain to
6269 /// be considered final, preventing any further rollback `[default: 2160]`.
6370 pub network_security_parameter : BlockNumber ,
@@ -164,6 +171,7 @@ impl Configuration {
164171 db_directory : PathBuf :: new ( ) ,
165172 network : "devnet" . to_string ( ) ,
166173 network_magic : Some ( 42 ) ,
174+ dmq_network_magic : Some ( 3141592 ) ,
167175 network_security_parameter : BlockNumber ( 2160 ) ,
168176 preload_security_parameter : BlockNumber ( 30 ) ,
169177 party_id : Some ( party_id) ,
@@ -195,7 +203,7 @@ impl Configuration {
195203 }
196204 }
197205
198- /// Return the CardanoNetwork value from the configuration.
206+ /// Return the Cardano network value from the configuration.
199207 pub fn get_network ( & self ) -> StdResult < CardanoNetwork > {
200208 CardanoNetwork :: from_code ( self . network . clone ( ) , self . network_magic ) . with_context ( || {
201209 format ! (
@@ -205,6 +213,17 @@ impl Configuration {
205213 } )
206214 }
207215
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+
208227 /// Create the SQL store directory if not exist and return the path of the
209228 /// SQLite3 file.
210229 pub fn get_sqlite_file ( & self , sqlite_file_name : & str ) -> StdResult < PathBuf > {
0 commit comments