@@ -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 ,
@@ -70,32 +94,22 @@ pub struct SignerRelay {
70
94
71
95
impl SignerRelay {
72
96
/// Start a relay for a Mithril signer
73
- pub async fn start (
74
- address : & Multiaddr ,
75
- server_port : & u16 ,
76
- #[ cfg( feature = "future_dmq" ) ] dmq_node_socket_path : & Path ,
77
- #[ cfg( feature = "future_dmq" ) ] cardano_network : & CardanoNetwork ,
78
- signer_registration_mode : & SignerRelayMode ,
79
- signature_registration_mode : & SignerRelayMode ,
80
- aggregator_endpoint : & str ,
81
- signer_repeater_delay : & Duration ,
82
- logger : & Logger ,
83
- ) -> StdResult < Self > {
84
- let relay_logger = logger. new_with_component_name :: < Self > ( ) ;
85
- debug ! ( relay_logger, "Starting..." ; "signer_registration_mode" => ?signer_registration_mode, "signature_registration_mode" => ?signature_registration_mode) ;
97
+ pub async fn start ( config : SignerRelayConfiguration < ' _ > ) -> StdResult < Self > {
98
+ let relay_logger = config. logger . new_with_component_name :: < Self > ( ) ;
99
+ debug ! ( relay_logger, "Starting..." ; "signer_registration_mode" => ?config. signer_registration_mode, "signature_registration_mode" => ?config. signature_registration_mode) ;
86
100
let ( signature_tx, signature_rx) = unbounded_channel :: < RegisterSignatureMessageHttp > ( ) ;
87
101
let ( signer_tx, signer_rx) = unbounded_channel :: < RegisterSignerMessage > ( ) ;
88
102
let signer_repeater = Arc :: new ( MessageRepeater :: new (
89
103
signer_tx. clone ( ) ,
90
- signer_repeater_delay. to_owned ( ) ,
91
- logger,
104
+ config . signer_repeater_delay . to_owned ( ) ,
105
+ config . logger ,
92
106
) ) ;
93
- let peer = Peer :: new ( address) . start ( ) . await ?;
107
+ let peer = Peer :: new ( config . address ) . start ( ) . await ?;
94
108
let http_server = Self :: start_http_server ( & HTTPServerConfiguration {
95
- server_port,
96
- signer_registration_mode : signer_registration_mode. to_owned ( ) ,
97
- signature_registration_mode : signature_registration_mode. to_owned ( ) ,
98
- aggregator_endpoint,
109
+ server_port : config . server_port ,
110
+ signer_registration_mode : config . signer_registration_mode . to_owned ( ) ,
111
+ signature_registration_mode : config . signature_registration_mode . to_owned ( ) ,
112
+ aggregator_endpoint : config . aggregator_endpoint ,
99
113
signer_tx : signer_tx. clone ( ) ,
100
114
signature_tx : signature_tx. clone ( ) ,
101
115
signer_repeater : signer_repeater. clone ( ) ,
@@ -110,8 +124,8 @@ impl SignerRelay {
110
124
let ( signature_dmq_tx, signature_dmq_rx) = unbounded_channel :: < DmqMessage > ( ) ;
111
125
#[ cfg( unix) ]
112
126
let _dmq_publisher_server = Self :: start_dmq_publisher_server (
113
- dmq_node_socket_path,
114
- cardano_network,
127
+ config . dmq_node_socket_path ,
128
+ config . cardano_network ,
115
129
signature_dmq_tx,
116
130
stop_rx,
117
131
relay_logger. clone ( ) ,
0 commit comments