Skip to content

Commit 0800bdd

Browse files
committed
feat(signer): add support for skipping the signature delayer
1 parent fb5cda7 commit 0800bdd

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

mithril-signer/src/configuration.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ pub struct SignaturePublisherConfig {
2525

2626
/// Delay (in milliseconds) between two separate publications done by the delayer signature publisher
2727
pub delayer_delay_ms: u64,
28+
29+
/// Whether to skip the delayer when publishing the signature
30+
///
31+
/// If set to true, the signatures will be published only once:
32+
/// - if the 'future_dmq` feature is used to compile, the signatures will be published only with the DMQ protocol
33+
/// - if the `future_dmq` feature is not used, the signatures will be published with the regular HTTP protocol
34+
pub skip_delayer: bool,
2835
}
2936

3037
/// Client configuration
@@ -137,7 +144,7 @@ pub struct Configuration {
137144
pub preloading_refresh_interval_in_seconds: u64,
138145

139146
/// Signature publisher configuration
140-
#[example = "`{ retry_attempts: 3, retry_delay_ms: 2000, delayer_delay_ms: 10000 }`"]
147+
#[example = "`{ retry_attempts: 3, retry_delay_ms: 2000, delayer_delay_ms: 10000, skip_delayer: false }`"]
141148
pub signature_publisher_config: SignaturePublisherConfig,
142149
}
143150

@@ -183,6 +190,7 @@ impl Configuration {
183190
retry_attempts: 1,
184191
retry_delay_ms: 1,
185192
delayer_delay_ms: 1,
193+
skip_delayer: false,
186194
},
187195
}
188196
}

mithril-signer/src/dependency_injection/builder.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -459,12 +459,20 @@ impl<'a> DependenciesBuilder<'a> {
459459
},
460460
);
461461

462-
Arc::new(SignaturePublisherDelayer::new(
463-
Arc::new(first_publisher),
464-
Arc::new(second_publisher),
465-
Duration::from_millis(self.config.signature_publisher_config.delayer_delay_ms),
466-
self.root_logger(),
467-
))
462+
if self.config.signature_publisher_config.skip_delayer {
463+
if cfg!(feature = "future_dmq") {
464+
Arc::new(first_publisher) as Arc<dyn SignaturePublisher>
465+
} else {
466+
Arc::new(second_publisher) as Arc<dyn SignaturePublisher>
467+
}
468+
} else {
469+
Arc::new(SignaturePublisherDelayer::new(
470+
Arc::new(first_publisher),
471+
Arc::new(second_publisher),
472+
Duration::from_millis(self.config.signature_publisher_config.delayer_delay_ms),
473+
self.root_logger(),
474+
)) as Arc<dyn SignaturePublisher>
475+
}
468476
};
469477

470478
let certifier = Arc::new(SignerCertifierService::new(

mithril-signer/src/main.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,19 @@ pub struct Args {
108108
default_value_t = 10_000
109109
)]
110110
signature_publisher_delayer_delay_ms: u64,
111+
112+
/// Whether to skip the delayer when publishing the signature
113+
///
114+
/// If set to true, the signatures will be published only once:
115+
/// - if the 'future_dmq` feature is used to compile, the signatures will be published only with the DMQ protocol
116+
/// - if the `future_dmq` feature is not used, the signatures will be published with the regular HTTP protocol
117+
118+
#[clap(
119+
long,
120+
env = "SIGNATURE_PUBLISHER_SKIP_DELAYER",
121+
default_value_t = false
122+
)]
123+
signature_publisher_skip_delayer: bool,
111124
}
112125

113126
impl Args {
@@ -207,6 +220,10 @@ async fn main() -> StdResult<()> {
207220
"signature_publisher_config.delayer_delay_ms",
208221
args.signature_publisher_delayer_delay_ms,
209222
)?
223+
.set_default(
224+
"signature_publisher_config.skip_delayer",
225+
args.signature_publisher_skip_delayer,
226+
)?
210227
.add_source(DefaultConfiguration::default())
211228
.add_source(
212229
config::File::with_name(&format!(

0 commit comments

Comments
 (0)