Skip to content

Commit b448f89

Browse files
committed
refactor: use sub module for P2P topic names
1 parent 9772cab commit b448f89

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

mithril-relay/src/lib.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ pub use relay::AggregatorRelay;
1313
pub use relay::PassiveRelay;
1414
pub use relay::SignerRelay;
1515

16-
/// The topic name where signer registrations are published
17-
pub const MITHRIL_SIGNERS_TOPIC_NAME: &str = "mithril/signers";
16+
/// The P2P topic names used by Mithril
17+
pub mod mithril_p2p_topic {
18+
/// The topic name where signer registrations are published
19+
pub const SIGNERS: &str = "mithril/signers";
1820

19-
/// The topic name where signatures are published
20-
pub const MITHRIL_SIGNATURES_TOPIC_NAME: &str = "mithril/signatures";
21+
/// The topic name where signatures are published
22+
pub const SIGNATURES: &str = "mithril/signatures";
23+
}

mithril-relay/src/p2p/peer.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use serde::{Deserialize, Serialize};
1616
use slog_scope::{debug, info};
1717
use std::{collections::HashMap, time::Duration};
1818

19-
use crate::{p2p::PeerError, MITHRIL_SIGNATURES_TOPIC_NAME, MITHRIL_SIGNERS_TOPIC_NAME};
19+
use crate::{mithril_p2p_topic, p2p::PeerError};
2020

2121
/// The idle connection timeout for a P2P connection
2222
const P2P_IDLE_CONNECTION_TIMEOUT: Duration = Duration::from_secs(30);
@@ -91,12 +91,12 @@ impl Peer {
9191
fn build_topics() -> HashMap<TopicName, gossipsub::IdentTopic> {
9292
HashMap::from([
9393
(
94-
MITHRIL_SIGNATURES_TOPIC_NAME.into(),
95-
gossipsub::IdentTopic::new(MITHRIL_SIGNATURES_TOPIC_NAME),
94+
mithril_p2p_topic::SIGNATURES.into(),
95+
gossipsub::IdentTopic::new(mithril_p2p_topic::SIGNATURES),
9696
),
9797
(
98-
MITHRIL_SIGNERS_TOPIC_NAME.into(),
99-
gossipsub::IdentTopic::new(MITHRIL_SIGNERS_TOPIC_NAME),
98+
mithril_p2p_topic::SIGNERS.into(),
99+
gossipsub::IdentTopic::new(mithril_p2p_topic::SIGNERS),
100100
),
101101
])
102102
}
@@ -214,7 +214,7 @@ impl Peer {
214214
) -> StdResult<gossipsub::MessageId> {
215215
self.publish_broadcast_message(
216216
&BroadcastMessage::RegisterSignature(message.to_owned()),
217-
MITHRIL_SIGNATURES_TOPIC_NAME,
217+
mithril_p2p_topic::SIGNATURES,
218218
)
219219
}
220220

@@ -261,7 +261,7 @@ impl Peer {
261261
) -> StdResult<gossipsub::MessageId> {
262262
self.publish_broadcast_message(
263263
&BroadcastMessage::RegisterSigner(message.to_owned()),
264-
MITHRIL_SIGNERS_TOPIC_NAME,
264+
mithril_p2p_topic::SIGNERS,
265265
)
266266
}
267267

0 commit comments

Comments
 (0)