summaryrefslogtreecommitdiff
path: root/src/Contact.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2021-12-26 22:22:34 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2021-12-27 13:57:07 +0100
commit2903fd39c39357168a7cbb8b6821a0c99ed1e5a7 (patch)
tree75f58e2ea12f57a9381fda69e14f955a45e26592 /src/Contact.hs
parented2fd1bf1f2e24565530bcfc9853cacbfa1c2a2a (diff)
Generalize local state helper functions
Diffstat (limited to 'src/Contact.hs')
-rw-r--r--src/Contact.hs10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/Contact.hs b/src/Contact.hs
index 9accc4d..e0f1a74 100644
--- a/src/Contact.hs
+++ b/src/Contact.hs
@@ -123,17 +123,15 @@ contactAccept printMsg h peer = do
return (Nothing, OurRequestReady)
OurRequestConfirm (Just ContactAccepted) -> do
PeerIdentityFull pid <- peerIdentity peer
- liftIO $ do
- printMsg $ "Contact accepted"
- updateLocalState_ h $ finalizeContact pid
+ liftIO $ printMsg $ "Contact accepted"
+ flip runReaderT h $ updateLocalState_ $ finalizeContact pid
return (Nothing, PairingDone)
OurRequestReady -> throwError $ "alredy accepted, waiting for peer"
PeerRequest {} -> throwError $ "waiting for peer"
PeerRequestConfirm -> do
PeerIdentityFull pid <- peerIdentity peer
- liftIO $ do
- printMsg $ "Contact accepted"
- updateLocalState_ h $ finalizeContact pid
+ liftIO $ printMsg $ "Contact accepted"
+ flip runReaderT h $ updateLocalState_ $ finalizeContact pid
return (Just $ PairingAccept ContactAccepted, PairingDone)
PairingDone -> throwError $ "alredy done"
PairingFailed -> throwError $ "alredy failed"