diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-09-14 15:58:04 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-09-14 15:58:04 -0400 |
commit | a68caf8b54b9d37deeaeddc6a28394d1587f1dc5 (patch) | |
tree | fea62c654da0db4842da833dea71ffe1fd6684bc /Storage.hs | |
parent | 92f0a9c8b6c676281dcbee6e4bce938b969ef7c2 (diff) | |
download | keysafe-a68caf8b54b9d37deeaeddc6a28394d1587f1dc5.tar.gz |
use multiple threads for chaffing
Diffstat (limited to 'Storage.hs')
-rw-r--r-- | Storage.hs | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -21,6 +21,7 @@ import System.IO import System.FilePath import Control.Monad import Crypto.Random +import Control.Concurrent.Async import qualified Data.Set as S import Network.Wai.Handler.Warp (Port) @@ -143,19 +144,19 @@ storeChaff hn port = forever $ do -- Prefix "random chaff" to the name to avoid ever using a name -- that a real user might want to use. let sis = shareIdents testModeTunables (Name $ "random chaff:" <> randomname) (KeyFile "random") - go sis rng' (concat (repeat knownObjectSizes)) + mapConcurrently (go sis rng' (concat (repeat knownObjectSizes))) + [1..totalObjects (shareParams testModeTunables)] where server = networkStorage Nothing $ Server hn port - go _ _ [] = return () - go sis rng (s:sizes) = do + go _ _ [] _ = return () + go sis rng (s:sizes) n = do let (b, rng') = cprgGenerate s rng let share = Share 0 (StorableObject b) - let ident = StorableObjectIdent let (is, sis') = nextShareIdents sis - let i = head (S.toList is) + let i = S.toList is !! (n - 1) r <- storeShare server i share case r of StoreSuccess -> putStr "." _ -> putStr "!" hFlush stdout - go sis' rng' sizes + go sis' rng' sizes n |