Skip to content

Commit f6a8f65

Browse files
committed
Move functions from Runner trait to the implementation and fix PR remarks
1 parent 1298283 commit f6a8f65

File tree

5 files changed

+25
-57
lines changed

5 files changed

+25
-57
lines changed

mithril-aggregator/src/message_adapters/to_certificate_pending_message.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ mod tests {
7676
}
7777

7878
#[test]
79+
#[allow(deprecated)]
7980
fn adapt_signers() {
8081
let fake_signers = fake_data::signers(5);
8182
let signers = fake_signers[1..3].to_vec();

mithril-common/src/messages/epoch_settings.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub struct EpochSettingsMessage {
1515
/// Next Protocol parameters
1616
#[serde(rename = "next_protocol")]
1717
pub next_protocol_parameters: ProtocolParameters,
18+
1819
/// Current Signers
1920
pub current_signers: Vec<SignerMessagePart>,
2021

mithril-common/src/messages/message_parts/signer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl SignerMessagePart {
182182
pub fn try_into_signers(messages: Vec<Self>) -> StdResult<Vec<Signer>> {
183183
messages
184184
.into_iter()
185-
.map(|m| SignerMessagePart::try_into(m))
185+
.map(SignerMessagePart::try_into)
186186
.collect()
187187
}
188188

mithril-signer/src/runtime/runner.rs

Lines changed: 20 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,6 @@ pub trait Runner: Send + Sync {
3030
/// Fetch the current time point from the Cardano node.
3131
async fn get_current_time_point(&self) -> StdResult<TimePoint>;
3232

33-
/// Get the current signers.
34-
/// // TODO return a &Vec
35-
async fn get_current_signers(&self) -> StdResult<Vec<Signer>>;
36-
37-
/// Get the next signers.
38-
async fn get_next_signers(&self) -> StdResult<Vec<Signer>>;
39-
40-
/// Get the next signers with their stake.
41-
async fn get_current_signers_with_stake(&self) -> StdResult<Vec<SignerWithStake>>;
42-
43-
/// Get the next signers with their stake.
44-
async fn get_next_signers_with_stake(&self) -> StdResult<Vec<SignerWithStake>>;
45-
4633
/// Register the signer verification key to the aggregator.
4734
async fn register_signer_to_aggregator(&self) -> StdResult<()>;
4835

@@ -110,6 +97,26 @@ impl SignerRunner {
11097
pub fn new(config: Configuration, services: SignerDependencyContainer) -> Self {
11198
Self { services, config }
11299
}
100+
101+
/// Get the current signers with their stake.
102+
async fn get_current_signers_with_stake(&self) -> StdResult<Vec<SignerWithStake>> {
103+
self.services
104+
.epoch_service
105+
.read()
106+
.await
107+
.current_signers_with_stake()
108+
.await
109+
}
110+
111+
/// Get the next signers with their stake.
112+
async fn get_next_signers_with_stake(&self) -> StdResult<Vec<SignerWithStake>> {
113+
self.services
114+
.epoch_service
115+
.read()
116+
.await
117+
.next_signers_with_stake()
118+
.await
119+
}
113120
}
114121

115122
#[cfg_attr(test, automock)]
@@ -145,48 +152,6 @@ impl Runner for SignerRunner {
145152
.with_context(|| "Runner can not get current time point")
146153
}
147154

148-
async fn get_current_signers(&self) -> StdResult<Vec<Signer>> {
149-
debug!("RUNNER: get_current_signers");
150-
151-
self.services
152-
.epoch_service
153-
.read()
154-
.await
155-
.current_signers()
156-
.cloned()
157-
}
158-
159-
async fn get_next_signers(&self) -> StdResult<Vec<Signer>> {
160-
debug!("RUNNER: get_next_signers");
161-
162-
self.services
163-
.epoch_service
164-
.read()
165-
.await
166-
.next_signers()
167-
.cloned()
168-
}
169-
170-
/// Get the current signers with their stake.
171-
async fn get_current_signers_with_stake(&self) -> StdResult<Vec<SignerWithStake>> {
172-
self.services
173-
.epoch_service
174-
.read()
175-
.await
176-
.current_signers_with_stake()
177-
.await
178-
}
179-
180-
/// Get the next signers with their stake.
181-
async fn get_next_signers_with_stake(&self) -> StdResult<Vec<SignerWithStake>> {
182-
self.services
183-
.epoch_service
184-
.read()
185-
.await
186-
.next_signers_with_stake()
187-
.await
188-
}
189-
190155
async fn register_signer_to_aggregator(&self) -> StdResult<()> {
191156
debug!("RUNNER: register_signer_to_aggregator");
192157

mithril-signer/src/services/epoch_service.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::RunnerError;
1818
#[derive(Debug, Error)]
1919
pub enum EpochServiceError {
2020
/// Raised when service has not collected data at least once.
21-
#[error("Epoch service was not initialized, the function `inform_epoch` must be called first")]
21+
#[error("Epoch service was not initialized, the function `inform_epoch_settings` must be called first")]
2222
NotYetInitialized,
2323
}
2424

@@ -108,6 +108,7 @@ impl MithrilEpochService {
108108

109109
Ok(signers_with_stake)
110110
}
111+
111112
fn unwrap_data(&self) -> Result<&EpochData, EpochServiceError> {
112113
self.epoch_data
113114
.as_ref()

0 commit comments

Comments
 (0)