@@ -32,10 +32,14 @@ impl MpcTlsLeaderCtrl {
3232 Self { address }
3333 }
3434
35- /// Defers decryption of any incoming messages.
36- pub async fn defer_decryption ( & self ) -> Result < ( ) , MpcTlsError > {
35+ /// Enables or disables the decryption of any incoming messages.
36+ ///
37+ /// # Arguments
38+ ///
39+ /// * `enable` - Whether to enable or disable decryption.
40+ pub async fn enable_decryption ( & self , enable : bool ) -> Result < ( ) , MpcTlsError > {
3741 self . address
38- . send ( DeferDecryption )
42+ . send ( EnableDecryption { enable } )
3943 . await
4044 . map_err ( MpcTlsError :: actor) ?
4145 }
@@ -981,7 +985,7 @@ impl Handler<BackendMsgServerClosed> for MpcTlsLeader {
981985 }
982986}
983987
984- impl Dispatch < MpcTlsLeader > for DeferDecryption {
988+ impl Dispatch < MpcTlsLeader > for EnableDecryption {
985989 fn dispatch < R : FnOnce ( Self :: Return ) + Send > (
986990 self ,
987991 actor : & mut MpcTlsLeader ,
@@ -992,13 +996,13 @@ impl Dispatch<MpcTlsLeader> for DeferDecryption {
992996 }
993997}
994998
995- impl Handler < DeferDecryption > for MpcTlsLeader {
999+ impl Handler < EnableDecryption > for MpcTlsLeader {
9961000 async fn handle (
9971001 & mut self ,
998- _msg : DeferDecryption ,
1002+ msg : EnableDecryption ,
9991003 _ctx : & mut LudiCtx < Self > ,
1000- ) -> <DeferDecryption as Message >:: Return {
1001- self . defer_decryption ( ) . await
1004+ ) -> <EnableDecryption as Message >:: Return {
1005+ self . enable_decryption ( msg . enable )
10021006 }
10031007}
10041008
@@ -1048,7 +1052,7 @@ pub enum MpcTlsLeaderMsg {
10481052 BackendMsgGetNotify ( BackendMsgGetNotify ) ,
10491053 BackendMsgIsEmpty ( BackendMsgIsEmpty ) ,
10501054 BackendMsgServerClosed ( BackendMsgServerClosed ) ,
1051- DeferDecryption ( DeferDecryption ) ,
1055+ DeferDecryption ( EnableDecryption ) ,
10521056 Stop ( Stop ) ,
10531057}
10541058
@@ -1083,7 +1087,7 @@ pub enum MpcTlsLeaderMsgReturn {
10831087 BackendMsgGetNotify ( <BackendMsgGetNotify as Message >:: Return ) ,
10841088 BackendMsgIsEmpty ( <BackendMsgIsEmpty as Message >:: Return ) ,
10851089 BackendMsgServerClosed ( <BackendMsgServerClosed as Message >:: Return ) ,
1086- DeferDecryption ( <DeferDecryption as Message >:: Return ) ,
1090+ DeferDecryption ( <EnableDecryption as Message >:: Return ) ,
10871091 Stop ( <Stop as Message >:: Return ) ,
10881092}
10891093
@@ -1732,23 +1736,25 @@ impl Wrap<BackendMsgServerClosed> for MpcTlsLeaderMsg {
17321736 }
17331737}
17341738
1735- /// Message to start deferring the decryption.
1739+ /// Message to enable or disable the decryption of messages .
17361740#[ allow( missing_docs) ]
17371741#[ derive( Debug ) ]
1738- pub struct DeferDecryption ;
1742+ pub struct EnableDecryption {
1743+ pub enable : bool ,
1744+ }
17391745
1740- impl Message for DeferDecryption {
1746+ impl Message for EnableDecryption {
17411747 type Return = Result < ( ) , MpcTlsError > ;
17421748}
17431749
1744- impl From < DeferDecryption > for MpcTlsLeaderMsg {
1745- fn from ( value : DeferDecryption ) -> Self {
1750+ impl From < EnableDecryption > for MpcTlsLeaderMsg {
1751+ fn from ( value : EnableDecryption ) -> Self {
17461752 MpcTlsLeaderMsg :: DeferDecryption ( value)
17471753 }
17481754}
17491755
1750- impl Wrap < DeferDecryption > for MpcTlsLeaderMsg {
1751- fn unwrap_return ( ret : Self :: Return ) -> Result < <DeferDecryption as Message >:: Return , Error > {
1756+ impl Wrap < EnableDecryption > for MpcTlsLeaderMsg {
1757+ fn unwrap_return ( ret : Self :: Return ) -> Result < <EnableDecryption as Message >:: Return , Error > {
17521758 match ret {
17531759 Self :: Return :: DeferDecryption ( value) => Ok ( value) ,
17541760 _ => Err ( Error :: Wrapper ) ,
0 commit comments