@@ -23,9 +23,9 @@ use super::{
23
23
LocalError , RemoteError ,
24
24
} ;
25
25
use crate :: protocol:: {
26
- Artifact , BoxedFormat , BoxedRound , CommunicationInfo , DirectMessage , EchoBroadcast , EchoRoundParticipation ,
26
+ Artifact , BoxedFormat , BoxedRound , CommunicationInfo , DirectMessage , EchoBroadcast ,
27
27
EntryPoint , FinalizeOutcome , IdSet , NormalBroadcast , PartyId , Payload , Protocol , ProtocolMessage ,
28
- ProtocolMessagePart , ReceiveError , ReceiveErrorType , RoundId , TransitionInfo ,
28
+ ProtocolMessagePart , ReceiveError , ReceiveErrorType , RoundCommunicationInfo , RoundId , TransitionInfo ,
29
29
} ;
30
30
31
31
/// A set of types needed to execute a session.
@@ -97,13 +97,6 @@ impl AsRef<[u8]> for SessionId {
97
97
}
98
98
}
99
99
100
- #[ derive( Debug ) ]
101
- pub ( crate ) struct EchoRoundInfo < Verifier > {
102
- pub ( crate ) message_destinations : BTreeSet < Verifier > ,
103
- pub ( crate ) expecting_messages_from : IdSet < Verifier > ,
104
- pub ( crate ) expected_echos : BTreeSet < Verifier > ,
105
- }
106
-
107
100
/// An object encapsulating the currently active round, transport protocol,
108
101
/// and the database of messages and errors from the previous rounds.
109
102
#[ derive( Debug ) ]
@@ -114,8 +107,9 @@ pub struct Session<P: Protocol<SP::Verifier>, SP: SessionParameters> {
114
107
format : BoxedFormat ,
115
108
round : BoxedRound < SP :: Verifier , P > ,
116
109
message_destinations : BTreeSet < SP :: Verifier > ,
117
- communication_info : CommunicationInfo < SP :: Verifier > ,
118
- echo_round_info : Option < EchoRoundInfo < SP :: Verifier > > ,
110
+ main_round_cinfo : RoundCommunicationInfo < SP :: Verifier > ,
111
+ echo_round_cinfo : RoundCommunicationInfo < SP :: Verifier > ,
112
+ expected_echos : IdSet < SP :: Verifier > ,
119
113
echo_broadcast : SignedMessagePart < EchoBroadcast > ,
120
114
normal_broadcast : SignedMessagePart < NormalBroadcast > ,
121
115
transition_info : TransitionInfo ,
@@ -174,41 +168,21 @@ where
174
168
let normal = round. as_ref ( ) . make_normal_broadcast ( rng, & format) ?;
175
169
let normal_broadcast = SignedMessagePart :: new :: < SP > ( rng, & signer, & session_id, & transition_info. id ( ) , normal) ?;
176
170
177
- let communication_info = round. as_ref ( ) . communication_info ( ) ;
178
- let message_destinations = communication_info
171
+ let CommunicationInfo {
172
+ main_round : main_round_cinfo,
173
+ echo_round : echo_round_cinfo,
174
+ expected_echos,
175
+ } = round. as_ref ( ) . communication_info ( ) ;
176
+
177
+ let echo_round_cinfo = echo_round_cinfo. unwrap_or ( main_round_cinfo. clone ( ) ) ;
178
+ let expected_echos = expected_echos. unwrap_or ( echo_round_cinfo. expecting_messages_from . clone ( ) ) ;
179
+
180
+ let message_destinations = main_round_cinfo
179
181
. message_destinations
180
182
. difference ( & transcript. banned_ids ( ) )
181
183
. cloned ( )
182
184
. collect :: < BTreeSet < _ > > ( ) ;
183
185
184
- let round_sends_echo_broadcast = !echo_broadcast. payload ( ) . is_none ( ) ;
185
- let echo_round_info = match & communication_info. echo_round_participation {
186
- EchoRoundParticipation :: Default => {
187
- if round_sends_echo_broadcast {
188
- // Add our own echo message to the expected list because we expect it to be sent back from other nodes.
189
- let mut expected_echos = communication_info. expecting_messages_from . all ( ) . clone ( ) ;
190
- expected_echos. insert ( verifier. clone ( ) ) ;
191
- Some ( EchoRoundInfo {
192
- message_destinations : communication_info. message_destinations . clone ( ) ,
193
- // TODO: this is not correct in general
194
- expecting_messages_from : IdSet :: new_non_threshold (
195
- communication_info. message_destinations . clone ( ) ,
196
- ) ,
197
- expected_echos,
198
- } )
199
- } else {
200
- None
201
- }
202
- }
203
- EchoRoundParticipation :: Send => None ,
204
- EchoRoundParticipation :: Receive { echo_targets } => Some ( EchoRoundInfo {
205
- message_destinations : echo_targets. clone ( ) ,
206
- // TODO: this is not correct in general
207
- expecting_messages_from : IdSet :: new_non_threshold ( echo_targets. clone ( ) ) ,
208
- expected_echos : communication_info. expecting_messages_from . all ( ) . clone ( ) ,
209
- } ) ,
210
- } ;
211
-
212
186
Ok ( Self {
213
187
session_id,
214
188
signer,
@@ -219,8 +193,9 @@ where
219
193
normal_broadcast,
220
194
transition_info,
221
195
message_destinations,
222
- communication_info,
223
- echo_round_info,
196
+ main_round_cinfo,
197
+ echo_round_cinfo,
198
+ expected_echos,
224
199
transcript,
225
200
} )
226
201
}
@@ -343,7 +318,7 @@ where
343
318
344
319
let acceptable_round_ids = self
345
320
. transition_info
346
- . simultaneous_rounds ( self . echo_round_info . is_some ( ) ) ?;
321
+ . simultaneous_rounds ( self . echo_round_cinfo . is_some ( ) ) ?;
347
322
348
323
let message_for = if message_round_id == self . round_id ( ) {
349
324
if accum. message_is_being_processed ( from) {
@@ -431,7 +406,7 @@ where
431
406
/// Makes an accumulator for a new round.
432
407
pub fn make_accumulator ( & self ) -> RoundAccumulator < P , SP > {
433
408
RoundAccumulator :: new (
434
- & self . communication_info . expecting_messages_from ,
409
+ & self . main_round_cinfo . expecting_messages_from ,
435
410
self . transcript . banned_ids ( ) ,
436
411
)
437
412
}
@@ -484,6 +459,8 @@ where
484
459
let verifier = self . verifier ( ) . clone ( ) ;
485
460
let round_id = self . round_id ( ) ;
486
461
462
+ let echo_round = !self . echo_broadcast . payload ( ) . is_none ( ) ;
463
+
487
464
let transcript = self . transcript . update (
488
465
& round_id,
489
466
( verifier. clone ( ) , self . echo_broadcast ) ,
@@ -495,11 +472,13 @@ where
495
472
accum. still_have_not_sent_messages ,
496
473
) ?;
497
474
498
- if let Some ( echo_round_info ) = self . echo_round_info {
475
+ if echo_round {
499
476
let round = BoxedRound :: new_dynamic ( EchoRound :: < P , SP > :: new (
500
477
verifier,
501
478
transcript. echo_broadcasts ( & round_id) ?,
502
- echo_round_info,
479
+ self . echo_round_cinfo ,
480
+ self . expected_echos ,
481
+ transcript. banned_ids ( ) . clone ( ) ,
503
482
self . round ,
504
483
accum. payloads ,
505
484
accum. artifacts ,
0 commit comments