diff options
author | joe <joe@jerkface.net> | 2018-06-18 13:32:02 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2018-06-18 13:32:02 -0400 |
commit | a45b000e07a806e171f1e4701abd3e025382ecf3 (patch) | |
tree | 52b562e145a2c19ba255a73fdf914af953a39e11 /examples | |
parent | 19364a287f7083fc60beed2d6eae3dd71d27e737 (diff) |
Factored separate code-paths for Kademlia announce versus action
on search result.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/dhtd.hs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs index 28bfc9b4..7cf3393c 100644 --- a/examples/dhtd.hs +++ b/examples/dhtd.hs | |||
@@ -1009,10 +1009,14 @@ clientSession s@Session{..} sock cnum h = do | |||
1009 | (const method) | 1009 | (const method) |
1010 | announceSendData) | 1010 | announceSendData) |
1011 | dhtQuery | 1011 | dhtQuery |
1012 | doit :: Char -> Announcer -> AnnounceKey -> AnnounceMethod r -> r -> IO () | 1012 | doitR :: Char -> Announcer -> AnnounceKey -> AnnounceMethod r -> r -> IO () |
1013 | doit '+' = schedule | 1013 | doitR '+' = scheduleAnnounce |
1014 | doit '-' = \a k _ _ -> cancel a k | 1014 | doitR '-' = \a k _ _ -> cancel a k |
1015 | doit _ = \_ _ _ _ -> hPutClientChunk h "Starting(+) or canceling(-)?" | 1015 | doitR _ = \_ _ _ _ -> hPutClientChunk h "Starting(+) or canceling(-)?" |
1016 | doitL :: Char -> Announcer -> AnnounceKey -> SearchMethod r -> r -> IO () | ||
1017 | doitL '+' = scheduleSearch | ||
1018 | doitL '-' = \a k _ _ -> cancel a k | ||
1019 | doitL _ = \_ _ _ _ -> hPutClientChunk h "Starting(+) or canceling(-)?" | ||
1016 | matchingResult :: | 1020 | matchingResult :: |
1017 | ( Typeable stok | 1021 | ( Typeable stok |
1018 | , Typeable ptok | 1022 | , Typeable ptok |
@@ -1046,9 +1050,9 @@ clientSession s@Session{..} sock cnum h = do | |||
1046 | dta <- either (const Nothing) Just $ announceParseData dtastr | 1050 | dta <- either (const Nothing) Just $ announceParseData dtastr |
1047 | return $ do | 1051 | return $ do |
1048 | akey <- atomically $ packAnnounceKey announcer (method ++ ":" ++ dtastr) | 1052 | akey <- atomically $ packAnnounceKey announcer (method ++ ":" ++ dtastr) |
1049 | doit op announcer | 1053 | doitR op announcer |
1050 | akey | 1054 | akey |
1051 | (AnnounceMethod qsearch (Right asend) | 1055 | (AnnounceMethod qsearch asend |
1052 | (\nid -> R.kclosest (searchSpace qsearch) | 1056 | (\nid -> R.kclosest (searchSpace qsearch) |
1053 | searchK | 1057 | searchK |
1054 | nid | 1058 | nid |
@@ -1072,9 +1076,9 @@ clientSession s@Session{..} sock cnum h = do | |||
1072 | pub <- selectedKey | 1076 | pub <- selectedKey |
1073 | return $ do | 1077 | return $ do |
1074 | akey <- atomically $ packAnnounceKey announcer (method ++ ":" ++ dtastr) | 1078 | akey <- atomically $ packAnnounceKey announcer (method ++ ":" ++ dtastr) |
1075 | doit op announcer | 1079 | doitL op announcer |
1076 | akey | 1080 | akey |
1077 | (AnnounceMethod qsearch (Left $ asend pub) | 1081 | (SearchMethod qsearch (asend pub) |
1078 | (\nid -> R.kclosest (searchSpace qsearch) | 1082 | (\nid -> R.kclosest (searchSpace qsearch) |
1079 | searchK | 1083 | searchK |
1080 | nid | 1084 | nid |