|
1 |
| -//! Wraps the protocol and provides sync API to execute it |
| 1 | +//! Wraps the protocol defined as async function and provides sync API to execute it |
| 2 | +//! |
| 3 | +//! In `round_based` framework, MPC protocols are defined as async function. However, sometimes it |
| 4 | +//! may not be possible/desirable to have async runtime which drives the futures until completion. |
| 5 | +//! For such use-cases, we provide [`wrap_protocol`] function that wraps an MPC protocol defined as |
| 6 | +//! async function and returns the [`StateMachine`] that exposes sync API to carry out the protocol. |
2 | 7 |
|
3 | 8 | mod delivery;
|
4 | 9 | mod noop_waker;
|
@@ -176,6 +181,13 @@ pub type Delivery<M> = (Incomings<M>, Outgoings<M>);
|
176 | 181 | pub type MpcParty<M> = crate::MpcParty<M, Delivery<M>, Runtime<M>>;
|
177 | 182 |
|
178 | 183 | /// Wraps the protocol and provides sync API to execute it
|
| 184 | +/// |
| 185 | +/// Protocol is an async function that takes [`MpcParty`] as input. `MpcParty` contains |
| 186 | +/// channels (of incoming and outgoing messages) that protocol is expected to use, and |
| 187 | +/// a [`Runtime`]. Protocol is only allowed to `.await` on futures provided in `MpcParty`, |
| 188 | +/// such as polling next message from provided steam of incoming messages. If protocol |
| 189 | +/// polls an unknown future, executor won't know what to do with that, the protocol will |
| 190 | +/// be aborted and error returned. |
179 | 191 | pub fn wrap_protocol<'a, M, F>(
|
180 | 192 | protocol: impl FnOnce(MpcParty<M>) -> F,
|
181 | 193 | ) -> impl StateMachine<Output = F::Output, Msg = M> + 'a
|
|
0 commit comments