diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2024-07-18 20:34:31 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2024-07-18 20:35:50 +0200 |
commit | 1e05216b7c9a8ce60556bb8f5bbe016b6ef3a5d9 (patch) | |
tree | ca9a425ec7de2fa6e013af1e1d1d32fe918c30fe /src/Erebos/Network.hs | |
parent | 4684006e4dd4c42674ba17a35ba394c939674346 (diff) |
Network: avoid error message on superseded channel request
Diffstat (limited to 'src/Erebos/Network.hs')
-rw-r--r-- | src/Erebos/Network.hs | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/Erebos/Network.hs b/src/Erebos/Network.hs index 402e163..442285a 100644 --- a/src/Erebos/Network.hs +++ b/src/Erebos/Network.hs @@ -535,8 +535,12 @@ handlePacket identity secure peer chanSvc svcs (TransportHeader headers) prefs = liftSTM $ finalizedChannel peer ch identity _ -> return () - Rejected dgst -> do - logd $ "rejected by peer: " ++ show dgst + Rejected dgst + | peerRequest : _ <- mapMaybe (\case TrChannelRequest d -> Just d; _ -> Nothing) headers + , peerRequest < dgst + -> return () -- Our request was rejected due to lower priority + + | otherwise -> logd $ "rejected by peer: " ++ show dgst DataRequest dgst | secure || dgst `elem` plaintextRefs -> do @@ -607,9 +611,15 @@ handlePacket identity secure peer chanSvc svcs (TransportHeader headers) prefs = ChannelCookieWait {} -> return () ChannelCookieReceived {} -> process ChannelCookieConfirmed {} -> process - ChannelOurRequest our | dgst < refDigest (storedRef our) -> process - | otherwise -> reject - ChannelPeerRequest {} -> process + ChannelOurRequest our + | dgst < refDigest (storedRef our) -> process + | otherwise -> do + -- Reject peer channel request with lower priority + addHeader $ TrChannelRequest $ refDigest $ storedRef our + reject + ChannelPeerRequest prev + | dgst == wrDigest prev -> addHeader $ Acknowledged dgst + | otherwise -> process ChannelOurAccept {} -> reject ChannelEstablished {} -> process ChannelClosed {} -> return () |