@@ -113,6 +113,7 @@ pub struct Session<P: Protocol<SP::Verifier>, SP: SessionParameters> {
113
113
verifier : SP :: Verifier ,
114
114
format : BoxedFormat ,
115
115
round : BoxedRound < SP :: Verifier , P > ,
116
+ message_destinations : BTreeSet < SP :: Verifier > ,
116
117
communication_info : CommunicationInfo < SP :: Verifier > ,
117
118
echo_round_info : Option < EchoRoundInfo < SP :: Verifier > > ,
118
119
echo_broadcast : SignedMessagePart < EchoBroadcast > ,
@@ -174,6 +175,11 @@ where
174
175
let normal_broadcast = SignedMessagePart :: new :: < SP > ( rng, & signer, & session_id, & transition_info. id ( ) , normal) ?;
175
176
176
177
let communication_info = round. as_ref ( ) . communication_info ( ) ;
178
+ let message_destinations = communication_info
179
+ . message_destinations
180
+ . difference ( & transcript. banned_ids ( ) )
181
+ . cloned ( )
182
+ . collect :: < BTreeSet < _ > > ( ) ;
177
183
178
184
let round_sends_echo_broadcast = !echo_broadcast. payload ( ) . is_none ( ) ;
179
185
let echo_round_info = match & communication_info. echo_round_participation {
@@ -212,6 +218,7 @@ where
212
218
echo_broadcast,
213
219
normal_broadcast,
214
220
transition_info,
221
+ message_destinations,
215
222
communication_info,
216
223
echo_round_info,
217
224
transcript,
@@ -230,7 +237,7 @@ where
230
237
231
238
/// Returns the set of message destinations for the current round.
232
239
pub fn message_destinations ( & self ) -> & BTreeSet < SP :: Verifier > {
233
- & self . communication_info . message_destinations
240
+ & self . message_destinations
234
241
}
235
242
236
243
/// Creates the message to be sent to the given destination.
@@ -241,6 +248,12 @@ where
241
248
rng : & mut impl CryptoRngCore ,
242
249
destination : & SP :: Verifier ,
243
250
) -> Result < ( Message < SP :: Verifier > , ProcessedArtifact < SP > ) , LocalError > {
251
+ if !self . message_destinations . contains ( destination) {
252
+ return Err ( LocalError :: new (
253
+ "Destination {destination} is not in the set of message destinations for this round" ,
254
+ ) ) ;
255
+ }
256
+
244
257
let ( direct_message, artifact) = self
245
258
. round
246
259
. as_ref ( )
0 commit comments