@@ -14,6 +14,7 @@ use mithril_common::{
14
14
logging:: LoggerExtensions ,
15
15
messages:: { RegisterSignatureMessageHttp , RegisterSignerMessage } ,
16
16
} ;
17
+ use mithril_dmq:: DmqMessage ;
17
18
use serde:: { Deserialize , Serialize } ;
18
19
use slog:: { Logger , debug, info} ;
19
20
use std:: { collections:: HashMap , time:: Duration } ;
@@ -63,11 +64,14 @@ pub type TopicName = String;
63
64
/// The broadcast message received from a Gossip sub event
64
65
#[ derive( Serialize , Deserialize ) ]
65
66
pub enum BroadcastMessage {
66
- /// A signer registration message received from the Gossip sub
67
- RegisterSigner ( RegisterSignerMessage ) ,
67
+ /// A HTTP signer registration message received from the Gossip sub
68
+ RegisterSignerHttp ( RegisterSignerMessage ) ,
68
69
69
- /// A signature registration message received from the Gossip sub
70
- RegisterSignature ( RegisterSignatureMessageHttp ) ,
70
+ /// A HTTP signature registration message received from the Gossip sub
71
+ RegisterSignatureHttp ( RegisterSignatureMessageHttp ) ,
72
+
73
+ /// A DMQ signature registration message received from the Gossip sub
74
+ RegisterSignatureDmq ( DmqMessage ) ,
71
75
}
72
76
73
77
/// A peer in the P2P network
@@ -95,12 +99,16 @@ impl Peer {
95
99
fn build_topics ( ) -> HashMap < TopicName , gossipsub:: IdentTopic > {
96
100
HashMap :: from ( [
97
101
(
98
- mithril_p2p_topic:: SIGNATURES . into ( ) ,
99
- gossipsub:: IdentTopic :: new ( mithril_p2p_topic:: SIGNATURES ) ,
102
+ mithril_p2p_topic:: SIGNATURES_HTTP . into ( ) ,
103
+ gossipsub:: IdentTopic :: new ( mithril_p2p_topic:: SIGNATURES_HTTP ) ,
104
+ ) ,
105
+ (
106
+ mithril_p2p_topic:: SIGNATURES_DMQ . into ( ) ,
107
+ gossipsub:: IdentTopic :: new ( mithril_p2p_topic:: SIGNATURES_DMQ ) ,
100
108
) ,
101
109
(
102
- mithril_p2p_topic:: SIGNERS . into ( ) ,
103
- gossipsub:: IdentTopic :: new ( mithril_p2p_topic:: SIGNERS ) ,
110
+ mithril_p2p_topic:: SIGNERS_HTTP . into ( ) ,
111
+ gossipsub:: IdentTopic :: new ( mithril_p2p_topic:: SIGNERS_HTTP ) ,
104
112
) ,
105
113
] )
106
114
}
@@ -217,14 +225,25 @@ impl Peer {
217
225
}
218
226
}
219
227
220
- /// Publish a signature on the P2P pubsub
221
- pub fn publish_signature (
228
+ /// Publish a HTTP signature on the P2P pubsub
229
+ pub fn publish_signature_http (
222
230
& mut self ,
223
231
message : & RegisterSignatureMessageHttp ,
224
232
) -> StdResult < gossipsub:: MessageId > {
225
233
self . publish_broadcast_message (
226
- & BroadcastMessage :: RegisterSignature ( message. to_owned ( ) ) ,
227
- mithril_p2p_topic:: SIGNATURES ,
234
+ & BroadcastMessage :: RegisterSignatureHttp ( message. to_owned ( ) ) ,
235
+ mithril_p2p_topic:: SIGNATURES_HTTP ,
236
+ )
237
+ }
238
+
239
+ /// Publish a DMQ signature on the P2P pubsub
240
+ pub fn publish_signature_dmq (
241
+ & mut self ,
242
+ message : & DmqMessage ,
243
+ ) -> StdResult < gossipsub:: MessageId > {
244
+ self . publish_broadcast_message (
245
+ & BroadcastMessage :: RegisterSignatureDmq ( message. to_owned ( ) ) ,
246
+ mithril_p2p_topic:: SIGNATURES_DMQ ,
228
247
)
229
248
}
230
249
@@ -270,8 +289,8 @@ impl Peer {
270
289
message : & RegisterSignerMessage ,
271
290
) -> StdResult < gossipsub:: MessageId > {
272
291
self . publish_broadcast_message (
273
- & BroadcastMessage :: RegisterSigner ( message. to_owned ( ) ) ,
274
- mithril_p2p_topic:: SIGNERS ,
292
+ & BroadcastMessage :: RegisterSignerHttp ( message. to_owned ( ) ) ,
293
+ mithril_p2p_topic:: SIGNERS_HTTP ,
275
294
)
276
295
}
277
296
0 commit comments