diff options
author | joe <joe@jerkface.net> | 2018-05-31 03:10:50 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2018-05-31 03:10:50 -0400 |
commit | fa03046702a5050c28c87f2e8ca3c86187e47ed1 (patch) | |
tree | acd53a1f673039376afd54e3d8565fb0adb544ab /examples | |
parent | 24fc5b3077dc8ea810a7b1d6c685a29c26562ad7 (diff) |
Nitpicking variable names.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/dhtd.hs | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs index 65d151ca..6a7695d2 100644 --- a/examples/dhtd.hs +++ b/examples/dhtd.hs | |||
@@ -926,34 +926,33 @@ clientSession s@Session{..} sock cnum h = do | |||
926 | case selectedKey of | 926 | case selectedKey of |
927 | Nothing -> hPutClient h "No key is selected, see k command." | 927 | Nothing -> hPutClient h "No key is selected, see k command." |
928 | Just mypubkey -> do | 928 | Just mypubkey -> do |
929 | let nidstr = strp s | 929 | let keystr = strp s |
930 | goParse = either | 930 | goParse = either |
931 | (\_ -> either (hPutClient h . ("Bad netcrypto target: "++)) | 931 | (\_ -> either (hPutClient h . ("Bad netcrypto target: "++)) |
932 | (goTarget . Left) | 932 | (goTarget . Left) |
933 | (readEither nidstr)) | 933 | (readEither keystr)) -- attempt read as NodeInfo type |
934 | (goTarget . Right . Tox.id2key) | 934 | (goTarget . Right . Tox.id2key) |
935 | $ readEither nidstr | 935 | $ readEither keystr -- attempt read as NodeId type |
936 | goTarget (Left nodeinfo) = do | 936 | goTarget (Left userkey_nodeinfo) = do |
937 | msec <- atomically $ do | 937 | msec <- atomically $ do |
938 | ks <- map swap <$> myKeyPairs roster | 938 | fmap userSecret . HashMap.lookup (Tox.key2id mypubkey) <$> readTVar (accounts roster) |
939 | return $ Data.List.lookup mypubkey ks | ||
940 | case mbTox of | 939 | case mbTox of |
941 | Nothing -> hPutClient h "Requires Tox enabled." | 940 | Nothing -> hPutClient h "Requires Tox enabled." |
942 | Just tox-> do | 941 | Just tox-> do |
943 | case msec of | 942 | case msec of |
944 | Nothing -> hPutClient h "Error getting secret key" | 943 | Nothing -> hPutClient h "Error getting secret key" |
945 | Just sec -> do | 944 | Just sec -> do |
946 | let nid = Tox.nodeId nodeinfo | 945 | let their_pub = Tox.id2key $ Tox.nodeId userkey_nodeinfo |
947 | naddr = Tox.nodeAddr nodeinfo | 946 | their_addr = Tox.nodeAddr userkey_nodeinfo |
948 | let acsVar = accounts (Tox.toxContactInfo tox) | 947 | let acsVar = accounts (Tox.toxContactInfo tox) |
949 | acsmap <- atomically $ readTVar acsVar | 948 | acsmap <- atomically $ readTVar acsVar |
950 | case HashMap.lookup (Tox.key2id mypubkey) acsmap of | 949 | case HashMap.lookup (Tox.key2id mypubkey) acsmap of |
951 | Nothing -> hPutClient h "Unable to find account for selected key" | 950 | Nothing -> hPutClient h "Unable to find account for selected key" |
952 | Just account -> do | 951 | Just account -> do |
953 | atomically $ setContactAddr (Tox.id2key nid) naddr account | 952 | atomically $ setContactAddr their_pub their_addr account |
954 | Tox.netCrypto tox sec (Tox.id2key nid) | 953 | Tox.netCrypto tox sec their_pub |
955 | hPutClient h "Handshake sent" | 954 | hPutClient h "Handshake sent" |
956 | goTarget (Right nid) = do | 955 | goTarget (Right their_pub) = do |
957 | msec <- atomically $ do | 956 | msec <- atomically $ do |
958 | ks <- map swap <$> myKeyPairs roster | 957 | ks <- map swap <$> myKeyPairs roster |
959 | return $ Data.List.lookup mypubkey ks | 958 | return $ Data.List.lookup mypubkey ks |
@@ -963,7 +962,7 @@ clientSession s@Session{..} sock cnum h = do | |||
963 | case msec of | 962 | case msec of |
964 | Nothing -> hPutClient h "Error getting secret key" | 963 | Nothing -> hPutClient h "Error getting secret key" |
965 | Just sec -> do | 964 | Just sec -> do |
966 | Tox.netCrypto tox sec nid | 965 | Tox.netCrypto tox sec their_pub |
967 | hPutClient h "Handshake sent" | 966 | hPutClient h "Handshake sent" |
968 | goParse | 967 | goParse |
969 | ("g", s) | Just DHT{..} <- Map.lookup netname dhts | 968 | ("g", s) | Just DHT{..} <- Map.lookup netname dhts |