@@ -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 , EchoRoundCommunicationInfo ,
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 : CommunicationInfo < SP :: Verifier > ,
111
+ echo_round_cinfo : CommunicationInfo < SP :: Verifier > ,
112
+ expected_echos : BTreeSet < SP :: Verifier > ,
119
113
echo_broadcast : SignedMessagePart < EchoBroadcast > ,
120
114
normal_broadcast : SignedMessagePart < NormalBroadcast > ,
121
115
transition_info : TransitionInfo ,
@@ -174,40 +168,39 @@ 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
+ } = round. as_ref ( ) . communication_info ( ) ;
175
+
176
+ let ( echo_round_cinfo, expected_echos) = match echo_round_cinfo {
177
+ EchoRoundCommunicationInfo :: None => {
178
+ let echo_round_cinfo = RoundCommunicationInfo :: none ( ) ;
179
+ let expected_echos = BTreeSet :: new ( ) ;
180
+ ( echo_round_cinfo, expected_echos)
181
+ }
182
+ EchoRoundCommunicationInfo :: SameAsMainRound => {
183
+ let echo_round_cinfo = main_round_cinfo. clone ( ) ;
184
+ let mut expected_echos = main_round_cinfo. expecting_messages_from . all ( ) . clone ( ) ;
185
+ // Add our own echo message to the expected list because we expect it to be sent back from other nodes.
186
+ expected_echos. insert ( verifier. clone ( ) ) ;
187
+ ( echo_round_cinfo, expected_echos)
188
+ }
189
+ EchoRoundCommunicationInfo :: Custom ( cinfo) => {
190
+ let mut expected_echos = main_round_cinfo. expecting_messages_from . all ( ) . clone ( ) ;
191
+ // Add our own echo message to the expected list because we expect it to be sent back from other nodes.
192
+ expected_echos. insert ( verifier. clone ( ) ) ;
193
+ ( cinfo, expected_echos)
194
+ }
195
+ } ;
196
+
197
+ let message_destinations = main_round_cinfo
179
198
. message_destinations
180
199
. difference ( & transcript. banned_ids ( ) )
181
200
. cloned ( )
182
201
. collect :: < BTreeSet < _ > > ( ) ;
183
202
184
203
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
204
212
205
Ok ( Self {
213
206
session_id,
0 commit comments