Skip to content

Commit 0344ca1

Browse files
committed
Remove signers assignation in FromPendingCertificateMessageAdapter
1 parent f6a8f65 commit 0344ca1

File tree

1 file changed

+8
-69
lines changed

1 file changed

+8
-69
lines changed
Lines changed: 8 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,28 @@
1-
use anyhow::Context;
1+
#![allow(deprecated)]
2+
23
use mithril_common::{
3-
crypto_helper::{
4-
ProtocolOpCert, ProtocolSignerVerificationKey, ProtocolSignerVerificationKeySignature,
5-
},
6-
entities::{CertificatePending, Signer},
7-
messages::{CertificatePendingMessage, SignerMessagePart, TryFromMessageAdapter},
4+
entities::CertificatePending,
5+
messages::{CertificatePendingMessage, TryFromMessageAdapter},
86
StdResult,
97
};
108

119
/// Adapter to turn [CertificatePendingMessage] instances into [CertificatePending].
1210
pub struct FromPendingCertificateMessageAdapter;
1311

14-
fn to_signers(messages: &[SignerMessagePart]) -> StdResult<Vec<Signer>> {
15-
let mut signers: Vec<Signer> = Vec::new();
16-
17-
for msg in messages {
18-
let signer = Signer::new(
19-
msg.party_id.to_owned(),
20-
ProtocolSignerVerificationKey::from_json_hex(&msg.verification_key)?,
21-
match &msg.verification_key_signature {
22-
Some(verification_key_signature) => Some(
23-
ProtocolSignerVerificationKeySignature::from_json_hex(
24-
verification_key_signature,
25-
)
26-
.with_context(|| {
27-
format!(
28-
"'FromPendingCertificateMessageAdapter' can not json hex decode the verification key signature: '{}'",
29-
verification_key_signature
30-
)
31-
})?,
32-
),
33-
_ => None,
34-
},
35-
match &msg.operational_certificate {
36-
Some(operational_certificate) => Some(
37-
ProtocolOpCert::from_json_hex(operational_certificate).with_context(|| {
38-
format!(
39-
"'FromPendingCertificateMessageAdapter' can not json hex decode the operational certificate: '{}'",
40-
operational_certificate
41-
)
42-
})?,
43-
),
44-
_ => None,
45-
},
46-
msg.kes_period,
47-
);
48-
signers.push(signer);
49-
}
50-
51-
Ok(signers)
52-
}
53-
5412
impl TryFromMessageAdapter<CertificatePendingMessage, CertificatePending>
5513
for FromPendingCertificateMessageAdapter
5614
{
5715
/// Adapter method
58-
#[allow(deprecated)]
5916
fn try_adapt(message: CertificatePendingMessage) -> StdResult<CertificatePending> {
6017
let certificate = CertificatePending {
6118
epoch: message.epoch,
6219
signed_entity_type: message.signed_entity_type,
6320
protocol_parameters: message.protocol_parameters,
6421
next_protocol_parameters: message.next_protocol_parameters,
65-
signers: to_signers(&message.signers).with_context(|| {
66-
format!(
67-
"'FromPendingCertificateMessageAdapter' can not convert the list of current signers: '{:?}'",
68-
message.signers
69-
)
70-
})?,
71-
next_signers: to_signers(&message.next_signers).with_context(|| {
72-
format!(
73-
"'FromPendingCertificateMessageAdapter' can not convert the list of next signers: '{:?}'",
74-
message.next_signers
75-
)
76-
})?,
22+
// This field is deprecated and should not be used in Signer.
23+
signers: vec![],
24+
// This field is deprecated and should not be used in Signer.
25+
next_signers: vec![],
7726
};
7827

7928
Ok(certificate)
@@ -92,14 +41,4 @@ mod tests {
9241

9342
assert_eq!(epoch, certificate_pending.epoch);
9443
}
95-
96-
#[test]
97-
fn adapt_signers() {
98-
let mut message = CertificatePendingMessage::dummy();
99-
message.signers = vec![SignerMessagePart::dummy(), SignerMessagePart::dummy()];
100-
let certificate_pending = FromPendingCertificateMessageAdapter::try_adapt(message).unwrap();
101-
102-
assert_eq!(2, certificate_pending.signers.len());
103-
assert_eq!(1, certificate_pending.next_signers.len());
104-
}
10544
}

0 commit comments

Comments
 (0)