1
- use anyhow:: Context ;
2
- use config:: { ConfigError , Map , Source , Value , ValueKind } ;
3
- use serde:: { Deserialize , Serialize } ;
4
1
use std:: collections:: { BTreeSet , HashMap , HashSet } ;
5
2
use std:: path:: PathBuf ;
6
3
use std:: str:: FromStr ;
7
4
5
+ use anyhow:: Context ;
6
+ use config:: { ConfigError , Map , Source , Value , ValueKind } ;
7
+ use serde:: { Deserialize , Serialize } ;
8
+
8
9
use mithril_cardano_node_chain:: chain_observer:: ChainObserverType ;
9
10
use mithril_cli_helper:: { register_config_value, serde_deserialization} ;
10
11
use mithril_common:: crypto_helper:: { ManifestSigner , ProtocolGenesisSigner } ;
@@ -14,6 +15,7 @@ use mithril_common::entities::{
14
15
SignedEntityTypeDiscriminants ,
15
16
} ;
16
17
use mithril_common:: { CardanoNetwork , StdResult } ;
18
+ use mithril_dmq:: DmqNetwork ;
17
19
use mithril_doc:: { Documenter , DocumenterDefault , StructDoc } ;
18
20
use mithril_era:: adapters:: EraReaderAdapterType ;
19
21
@@ -80,16 +82,24 @@ pub trait ConfigurationSource {
80
82
panic ! ( "cardano_node_version is not implemented." ) ;
81
83
}
82
84
85
+ /// Cardano network
86
+ fn network ( & self ) -> String {
87
+ panic ! ( "network is not implemented." ) ;
88
+ }
89
+
83
90
/// Cardano Network Magic number
84
91
///
85
92
/// useful for TestNet & DevNet
86
93
fn network_magic ( & self ) -> Option < u64 > {
87
94
panic ! ( "network_magic is not implemented." ) ;
88
95
}
89
96
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." ) ;
93
103
}
94
104
95
105
/// Cardano chain observer type
@@ -302,6 +312,13 @@ pub trait ConfigurationSource {
302
312
. with_context ( || "Invalid network configuration" )
303
313
}
304
314
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
+
305
322
/// Get the directory of the SQLite stores.
306
323
fn get_sqlite_dir ( & self ) -> PathBuf {
307
324
let store_dir = & self . data_stores_directory ( ) ;
@@ -409,15 +426,21 @@ pub struct ServeCommandConfiguration {
409
426
/// is why it has to be manually given to the Aggregator
410
427
pub cardano_node_version : String ,
411
428
412
- /// Cardano Network Magic number
429
+ /// Cardano network
430
+ #[ example = "`mainnet` or `preprod` or `devnet`" ]
431
+ pub network : String ,
432
+
433
+ /// Cardano network magic number
413
434
///
414
435
/// useful for TestNet & DevNet
415
436
#[ example = "`1097911063` or `42`" ]
416
437
pub network_magic : Option < u64 > ,
417
438
418
- /// Cardano network
419
- #[ example = "`mainnet` or `preprod` or `devnet`" ]
420
- pub network : String ,
439
+ /// Dmq network magic number
440
+ ///
441
+ /// useful for TestNet & DevNet
442
+ #[ example = "`1097911063` or `42`" ]
443
+ pub dmq_network_magic : Option < u64 > ,
421
444
422
445
/// Cardano chain observer type
423
446
pub chain_observer_type : ChainObserverType ,
@@ -636,8 +659,9 @@ impl ServeCommandConfiguration {
636
659
cardano_node_socket_path : PathBuf :: new ( ) ,
637
660
dmq_node_socket_path : None ,
638
661
cardano_node_version : "0.0.1" . to_string ( ) ,
639
- network_magic : Some ( 42 ) ,
640
662
network : "devnet" . to_string ( ) ,
663
+ network_magic : Some ( 42 ) ,
664
+ dmq_network_magic : Some ( 3141592 ) ,
641
665
chain_observer_type : ChainObserverType :: Fake ,
642
666
protocol_parameters : ProtocolParameters {
643
667
k : 5 ,
@@ -722,12 +746,16 @@ impl ConfigurationSource for ServeCommandConfiguration {
722
746
self . cardano_node_version . clone ( )
723
747
}
724
748
749
+ fn network ( & self ) -> String {
750
+ self . network . clone ( )
751
+ }
752
+
725
753
fn network_magic ( & self ) -> Option < u64 > {
726
754
self . network_magic
727
755
}
728
756
729
- fn network ( & self ) -> String {
730
- self . network . clone ( )
757
+ fn dmq_network_magic ( & self ) -> Option < u64 > {
758
+ self . dmq_network_magic
731
759
}
732
760
733
761
fn chain_observer_type ( & self ) -> ChainObserverType {
0 commit comments