1- use anyhow:: Context ;
2- use config:: { ConfigError , Map , Source , Value , ValueKind } ;
3- use serde:: { Deserialize , Serialize } ;
41use std:: collections:: { BTreeSet , HashMap , HashSet } ;
52use std:: path:: PathBuf ;
63use std:: str:: FromStr ;
74
5+ use anyhow:: Context ;
6+ use config:: { ConfigError , Map , Source , Value , ValueKind } ;
7+ use serde:: { Deserialize , Serialize } ;
8+
89use mithril_cardano_node_chain:: chain_observer:: ChainObserverType ;
910use mithril_cli_helper:: { register_config_value, serde_deserialization} ;
1011use mithril_common:: crypto_helper:: { ManifestSigner , ProtocolGenesisSigner } ;
@@ -14,6 +15,7 @@ use mithril_common::entities::{
1415 SignedEntityTypeDiscriminants ,
1516} ;
1617use mithril_common:: { AggregateSignatureType , CardanoNetwork , StdResult } ;
18+ use mithril_dmq:: DmqNetwork ;
1719use mithril_doc:: { Documenter , DocumenterDefault , StructDoc } ;
1820use mithril_era:: adapters:: EraReaderAdapterType ;
1921
@@ -80,16 +82,24 @@ pub trait ConfigurationSource {
8082 panic ! ( "cardano_node_version is not implemented." ) ;
8183 }
8284
85+ /// Cardano network
86+ fn network ( & self ) -> String {
87+ panic ! ( "network is not implemented." ) ;
88+ }
89+
8390 /// Cardano Network Magic number
8491 ///
8592 /// useful for TestNet & DevNet
8693 fn network_magic ( & self ) -> Option < u64 > {
8794 panic ! ( "network_magic is not implemented." ) ;
8895 }
8996
90- /// Cardano network
91- fn network ( & self ) -> String {
92- panic ! ( "network is not implemented." ) ;
97+ /// DMQ Network Magic number
98+ ///
99+ /// useful for TestNet & DevNet
100+ #[ cfg( feature = "future_dmq" ) ]
101+ fn dmq_network_magic ( & self ) -> Option < u64 > {
102+ panic ! ( "dmq_network_magic is not implemented." ) ;
93103 }
94104
95105 /// Cardano chain observer type
@@ -302,6 +312,13 @@ pub trait ConfigurationSource {
302312 . with_context ( || "Invalid network configuration" )
303313 }
304314
315+ /// Get a representation of the DMQ network.
316+ #[ cfg( feature = "future_dmq" ) ]
317+ fn get_dmq_network ( & self ) -> StdResult < DmqNetwork > {
318+ DmqNetwork :: from_code ( self . network ( ) , self . dmq_network_magic ( ) )
319+ . with_context ( || "Invalid DMQ network configuration" )
320+ }
321+
305322 /// Get the directory of the SQLite stores.
306323 fn get_sqlite_dir ( & self ) -> PathBuf {
307324 let store_dir = & self . data_stores_directory ( ) ;
@@ -414,15 +431,21 @@ pub struct ServeCommandConfiguration {
414431 /// is why it has to be manually given to the Aggregator
415432 pub cardano_node_version : String ,
416433
417- /// Cardano Network Magic number
434+ /// Cardano network
435+ #[ example = "`mainnet` or `preprod` or `devnet`" ]
436+ pub network : String ,
437+
438+ /// Cardano network magic number
418439 ///
419440 /// useful for TestNet & DevNet
420441 #[ example = "`1097911063` or `42`" ]
421442 pub network_magic : Option < u64 > ,
422443
423- /// Cardano network
424- #[ example = "`mainnet` or `preprod` or `devnet`" ]
425- pub network : String ,
444+ /// Dmq network magic number
445+ ///
446+ /// useful for TestNet & DevNet
447+ #[ example = "`1097911063` or `42`" ]
448+ pub dmq_network_magic : Option < u64 > ,
426449
427450 /// Cardano chain observer type
428451 pub chain_observer_type : ChainObserverType ,
@@ -644,8 +667,9 @@ impl ServeCommandConfiguration {
644667 cardano_node_socket_path : PathBuf :: new ( ) ,
645668 dmq_node_socket_path : None ,
646669 cardano_node_version : "0.0.1" . to_string ( ) ,
647- network_magic : Some ( 42 ) ,
648670 network : "devnet" . to_string ( ) ,
671+ network_magic : Some ( 42 ) ,
672+ dmq_network_magic : Some ( 3141592 ) ,
649673 chain_observer_type : ChainObserverType :: Fake ,
650674 protocol_parameters : ProtocolParameters {
651675 k : 5 ,
@@ -731,12 +755,16 @@ impl ConfigurationSource for ServeCommandConfiguration {
731755 self . cardano_node_version . clone ( )
732756 }
733757
758+ fn network ( & self ) -> String {
759+ self . network . clone ( )
760+ }
761+
734762 fn network_magic ( & self ) -> Option < u64 > {
735763 self . network_magic
736764 }
737765
738- fn network ( & self ) -> String {
739- self . network . clone ( )
766+ fn dmq_network_magic ( & self ) -> Option < u64 > {
767+ self . dmq_network_magic
740768 }
741769
742770 fn chain_observer_type ( & self ) -> ChainObserverType {
0 commit comments