@@ -56,6 +56,30 @@ struct HTTPServerConfiguration<'a> {
56
56
logger : & ' a Logger ,
57
57
}
58
58
59
+ /// Configuration for a Mithril Signer Relay
60
+ pub struct SignerRelayConfiguration < ' a > {
61
+ /// Address on which the HTTP server will listen
62
+ pub address : & ' a Multiaddr ,
63
+ /// Port on which the HTTP server will listen
64
+ pub server_port : & ' a u16 ,
65
+ /// Path to the DMQ node socket file
66
+ #[ cfg( feature = "future_dmq" ) ]
67
+ pub dmq_node_socket_path : & ' a Path ,
68
+ /// Cardano network
69
+ #[ cfg( feature = "future_dmq" ) ]
70
+ pub cardano_network : & ' a CardanoNetwork ,
71
+ /// Signer registration mode
72
+ pub signer_registration_mode : & ' a SignerRelayMode ,
73
+ /// Signature registration mode
74
+ pub signature_registration_mode : & ' a SignerRelayMode ,
75
+ /// Aggregator endpoint URL
76
+ pub aggregator_endpoint : & ' a str ,
77
+ /// Delay for repeating a signer registration message
78
+ pub signer_repeater_delay : & ' a Duration ,
79
+ /// Logger for the signer relay
80
+ pub logger : & ' a Logger ,
81
+ }
82
+
59
83
/// A relay for a Mithril signer
60
84
pub struct SignerRelay {
61
85
http_server : TestHttpServer ,
@@ -73,32 +97,22 @@ pub struct SignerRelay {
73
97
74
98
impl SignerRelay {
75
99
/// Start a relay for a Mithril signer
76
- pub async fn start (
77
- address : & Multiaddr ,
78
- server_port : & u16 ,
79
- #[ cfg( feature = "future_dmq" ) ] dmq_node_socket_path : & Path ,
80
- #[ cfg( feature = "future_dmq" ) ] cardano_network : & CardanoNetwork ,
81
- signer_registration_mode : & SignerRelayMode ,
82
- signature_registration_mode : & SignerRelayMode ,
83
- aggregator_endpoint : & str ,
84
- signer_repeater_delay : & Duration ,
85
- logger : & Logger ,
86
- ) -> StdResult < Self > {
87
- let relay_logger = logger. new_with_component_name :: < Self > ( ) ;
88
- debug ! ( relay_logger, "Starting..." ; "signer_registration_mode" => ?signer_registration_mode, "signature_registration_mode" => ?signature_registration_mode) ;
100
+ pub async fn start ( config : SignerRelayConfiguration < ' _ > ) -> StdResult < Self > {
101
+ let relay_logger = config. logger . new_with_component_name :: < Self > ( ) ;
102
+ debug ! ( relay_logger, "Starting..." ; "signer_registration_mode" => ?config. signer_registration_mode, "signature_registration_mode" => ?config. signature_registration_mode) ;
89
103
let ( signature_tx, signature_rx) = unbounded_channel :: < RegisterSignatureMessageHttp > ( ) ;
90
104
let ( signer_tx, signer_rx) = unbounded_channel :: < RegisterSignerMessage > ( ) ;
91
105
let signer_repeater = Arc :: new ( MessageRepeater :: new (
92
106
signer_tx. clone ( ) ,
93
- signer_repeater_delay. to_owned ( ) ,
94
- logger,
107
+ config . signer_repeater_delay . to_owned ( ) ,
108
+ config . logger ,
95
109
) ) ;
96
- let peer = Peer :: new ( address) . start ( ) . await ?;
110
+ let peer = Peer :: new ( config . address ) . start ( ) . await ?;
97
111
let http_server = Self :: start_http_server ( & HTTPServerConfiguration {
98
- server_port,
99
- signer_registration_mode : signer_registration_mode. to_owned ( ) ,
100
- signature_registration_mode : signature_registration_mode. to_owned ( ) ,
101
- aggregator_endpoint,
112
+ server_port : config . server_port ,
113
+ signer_registration_mode : config . signer_registration_mode . to_owned ( ) ,
114
+ signature_registration_mode : config . signature_registration_mode . to_owned ( ) ,
115
+ aggregator_endpoint : config . aggregator_endpoint ,
102
116
signer_tx : signer_tx. clone ( ) ,
103
117
signature_tx : signature_tx. clone ( ) ,
104
118
signer_repeater : signer_repeater. clone ( ) ,
@@ -113,8 +127,8 @@ impl SignerRelay {
113
127
let ( signature_dmq_tx, signature_dmq_rx) = unbounded_channel :: < DmqMessage > ( ) ;
114
128
#[ cfg( unix) ]
115
129
let _dmq_publisher_server = Self :: start_dmq_publisher_server (
116
- dmq_node_socket_path,
117
- cardano_network,
130
+ config . dmq_node_socket_path ,
131
+ config . cardano_network ,
118
132
signature_dmq_tx,
119
133
stop_rx,
120
134
relay_logger. clone ( ) ,
0 commit comments