summaryrefslogtreecommitdiff
path: root/src/Network.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2022-01-08 16:39:26 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2022-01-08 16:39:26 +0100
commit13c7c7ba82c455c077010b1d2fa6d0e332de7601 (patch)
tree0f6283712c5bd475f9809ea6e0d18687cfc6d395 /src/Network.hs
parentd1f00d188698c52c07a5881fc0088e4163976e5e (diff)
Channel: use counter to generate nonce
Diffstat (limited to 'src/Network.hs')
-rw-r--r--src/Network.hs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/Network.hs b/src/Network.hs
index e27c2a3..e78ae7c 100644
--- a/src/Network.hs
+++ b/src/Network.hs
@@ -138,7 +138,7 @@ data PeerIdentity = PeerIdentityUnknown (TVar [UnifiedIdentity -> ExceptT String
data PeerChannel = ChannelWait
| ChannelOurRequest (Stored ChannelRequest)
| ChannelPeerRequest WaitingRef
- | ChannelOurAccept (Stored ChannelAccept) (Stored Channel)
+ | ChannelOurAccept (Stored ChannelAccept) Channel
| ChannelEstablished Channel
peerIdentity :: MonadIO m => Peer -> m PeerIdentity
@@ -328,9 +328,9 @@ startServer opt origHead logd' services = do
case M.lookup paddr pvalue of
Just peer -> do
mbch <- atomically (readTVar (peerChannel peer)) >>= return . \case
- ChannelEstablished ch -> Just ch
- ChannelOurAccept _ sch -> Just $ fromStored sch
- _ -> Nothing
+ ChannelEstablished ch -> Just ch
+ ChannelOurAccept _ ch -> Just ch
+ _ -> Nothing
if | Just ch <- mbch
, Right plain <- runExcept $ channelDecrypt ch msg
@@ -492,7 +492,7 @@ handlePacket origHead identity secure peer chanSvc svcs (TransportHeader headers
Acknowledged ref -> do
readTVarP (peerChannel peer) >>= \case
ChannelOurAccept acc ch | refDigest (storedRef acc) == refDigest ref -> do
- writeTVarP (peerChannel peer) $ ChannelEstablished (fromStored ch)
+ writeTVarP (peerChannel peer) $ ChannelEstablished ch
liftSTM $ finalizedChannel peer origHead identity
_ -> return ()
@@ -630,7 +630,7 @@ handleChannelAccept oh identity accref = do
ch <- acceptedChannel identity upid (wrappedLoad acc)
liftIO $ atomically $ do
sendToPeerS peer $ TransportPacket (TransportHeader [Acknowledged accref]) []
- writeTVar (peerChannel peer) $ ChannelEstablished $ fromStored ch
+ writeTVar (peerChannel peer) $ ChannelEstablished ch
finalizedChannel peer oh identity
Left dgst -> throwError $ "missing accept data " ++ BC.unpack (showRefDigest dgst)