diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2019-05-06 21:06:45 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2019-05-06 21:06:45 +0200 |
commit | a0fbbe270135d9541a1a0d88bc980a6deab35a4a (patch) | |
tree | e53ac4fe2f39d228164b828055469a75f39c5e6f /src/Network.hs | |
parent | cbe15d1ce90aa07f5225510728f6071619bbe0d3 (diff) |
Generic collecting of objects through references
Diffstat (limited to 'src/Network.hs')
-rw-r--r-- | src/Network.hs | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/src/Network.hs b/src/Network.hs index 198efb0..f294835 100644 --- a/src/Network.hs +++ b/src/Network.hs @@ -17,7 +17,6 @@ import Network.Socket import Network.Socket.ByteString (recvFrom, sendTo) import Identity -import PubKey import Storage @@ -108,10 +107,7 @@ peerDiscovery bhost sidentity = do putStrLn $ "Got announce: " ++ show ref ++ " from " ++ show peer when (ref /= storedRef sidentity) $ void $ sendTo sock (BL.toStrict $ BL.concat [ serializeObject $ transportToObject $ IdentityRequest ref (storedRef sidentity) - , lazyLoadBytes $ storedRef sidentity - , lazyLoadBytes $ storedRef $ signedData $ fromStored sidentity - , lazyLoadBytes $ storedRef $ idKeyIdentity $ fromStored $ signedData $ fromStored sidentity - , lazyLoadBytes $ storedRef $ signedSignature $ fromStored sidentity + , BL.concat $ map (lazyLoadBytes . storedRef) $ collectStoredObjects $ wrappedLoad $ storedRef sidentity ]) peer packet _ _ peer (IdentityRequest ref from) [] = do @@ -126,10 +122,7 @@ peerDiscovery bhost sidentity = do writeChan chan $ Peer (wrappedLoad from) (DatagramAddress peer) void $ sendTo sock (BL.toStrict $ BL.concat [ serializeObject $ transportToObject $ IdentityResponse (storedRef sidentity) - , lazyLoadBytes $ storedRef sidentity - , lazyLoadBytes $ storedRef $ signedData $ fromStored sidentity - , lazyLoadBytes $ storedRef $ idKeyIdentity $ fromStored $ signedData $ fromStored sidentity - , lazyLoadBytes $ storedRef $ signedSignature $ fromStored sidentity + , BL.concat $ map (lazyLoadBytes . storedRef) $ collectStoredObjects $ wrappedLoad $ storedRef sidentity ]) peer else putStrLn $ "Mismatched content" |