Commit 599cc69 1 parent 687132f commit 599cc69 Copy full SHA for 599cc69
File tree 1 file changed +19
-2
lines changed
round-based/src/simulation
1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -248,8 +248,7 @@ where
248
248
{
249
249
let mut sim = Self :: with_capacity ( n) ;
250
250
for i in 0 ..n {
251
- let party = crate :: state_machine:: wrap_protocol ( |party| init ( i, party) ) ;
252
- sim. add_party ( party)
251
+ sim. add_async_party ( |party| init ( i, party) )
253
252
}
254
253
sim
255
254
}
@@ -282,6 +281,24 @@ where
282
281
} )
283
282
}
284
283
284
+ /// Adds new party, defined as an async function, into the protocol
285
+ ///
286
+ /// New party will be assigned index `i = n - 1` where `n` is amount of parties in the
287
+ /// simulation after this party was added.
288
+ ///
289
+ /// Async function will be converted into a [state machine](crate::state_machine). Because of that,
290
+ /// it cannot await on any futures that aren't provided by `MpcParty` (that is given as an argument
291
+ /// to this function).
292
+ pub fn add_async_party < F > ( & mut self , party : impl FnOnce ( crate :: state_machine:: MpcParty < M > ) -> F )
293
+ where
294
+ F : core:: future:: Future < Output = O > + ' a ,
295
+ {
296
+ self . parties . push ( Party :: Active {
297
+ party : Box :: new ( crate :: state_machine:: wrap_protocol ( party) ) ,
298
+ wants_one_more_msg : false ,
299
+ } )
300
+ }
301
+
285
302
/// Returns amount of parties in the simulation
286
303
pub fn parties_amount ( & self ) -> usize {
287
304
self . parties . len ( )
You can’t perform that action at this time.
0 commit comments