Skip to content

Commit 456f1e1

Browse files
committed
chore(signer): use 'DmqNetwork' model
1 parent 5a09ae0 commit 456f1e1

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

mithril-signer/src/configuration.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use anyhow::Context;
22
use config::{ConfigError, Map, Source, Value};
3+
#[cfg(feature = "future_dmq")]
4+
use mithril_dmq::DmqNetwork;
35
use mithril_doc::{Documenter, DocumenterDefault, StructDoc};
46
use serde::{Deserialize, Serialize};
57
use 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> {

mithril-signer/src/dependency_injection/builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ impl<'a> DependenciesBuilder<'a> {
422422
let first_publisher = SignaturePublisherRetrier::new(
423423
match &self.config.dmq_node_socket_path {
424424
Some(dmq_node_socket_path) => {
425-
let cardano_network = &self.config.get_network()?;
425+
let dmq_network = &self.config.get_dmq_network()?;
426426
let dmq_message_builder = DmqMessageBuilder::new(
427427
kes_signer
428428
.clone()
@@ -432,7 +432,7 @@ impl<'a> DependenciesBuilder<'a> {
432432
Arc::new(SignaturePublisherDmq::new(Arc::new(
433433
DmqPublisherClientPallas::<RegisterSignatureMessageDmq>::new(
434434
dmq_node_socket_path.to_owned(),
435-
*cardano_network,
435+
*dmq_network,
436436
dmq_message_builder,
437437
self.root_logger(),
438438
),

0 commit comments

Comments
 (0)