@@ -34,7 +34,12 @@ pub(crate) enum EchoRoundError<Id> {
34
34
///
35
35
/// The attached identifier points out the sender for whom the echoed message was invalid,
36
36
/// to speed up the verification process.
37
- InvalidEcho ( Id ) ,
37
+ InvalidEcho {
38
+ // Even though this will be the same as the message sender, it is convenient to record it here
39
+ // because of the way this error will be processed.
40
+ guilty_party : Id ,
41
+ failed_for : Id ,
42
+ } ,
38
43
/// The originally received message and the one received in the echo pack were both valid,
39
44
/// but different.
40
45
///
@@ -49,7 +54,7 @@ pub(crate) enum EchoRoundError<Id> {
49
54
impl < Id > EchoRoundError < Id > {
50
55
pub ( crate ) fn description ( & self ) -> String {
51
56
match self {
52
- Self :: InvalidEcho ( _ ) => "Invalid message received among the ones echoed" . into ( ) ,
57
+ Self :: InvalidEcho { .. } => "Invalid message received among the ones echoed" . into ( ) ,
53
58
Self :: MismatchedBroadcasts { .. } => {
54
59
"The echoed message is different from the originally received one" . into ( )
55
60
}
@@ -236,17 +241,29 @@ where
236
241
// This means `from` sent us an incorrectly signed message.
237
242
// Provable fault of `from`.
238
243
Err ( MessageVerificationError :: InvalidSignature ) => {
239
- return Err ( EchoRoundError :: InvalidEcho ( sender. clone ( ) ) . into ( ) )
244
+ return Err ( EchoRoundError :: InvalidEcho {
245
+ guilty_party : from. clone ( ) ,
246
+ failed_for : sender. clone ( ) ,
247
+ }
248
+ . into ( ) )
240
249
}
241
250
Err ( MessageVerificationError :: SignatureMismatch ) => {
242
- return Err ( EchoRoundError :: InvalidEcho ( sender. clone ( ) ) . into ( ) )
251
+ return Err ( EchoRoundError :: InvalidEcho {
252
+ guilty_party : from. clone ( ) ,
253
+ failed_for : sender. clone ( ) ,
254
+ }
255
+ . into ( ) )
243
256
}
244
257
} ;
245
258
246
259
// `from` sent us a correctly signed message but from another round or another session.
247
260
// Provable fault of `from`.
248
261
if verified_echo. metadata ( ) != previously_received_echo. metadata ( ) {
249
- return Err ( EchoRoundError :: InvalidEcho ( sender. clone ( ) ) . into ( ) ) ;
262
+ return Err ( EchoRoundError :: InvalidEcho {
263
+ guilty_party : from. clone ( ) ,
264
+ failed_for : sender. clone ( ) ,
265
+ }
266
+ . into ( ) ) ;
250
267
}
251
268
252
269
// `sender` sent us and `from` messages with different payloads,
0 commit comments