summaryrefslogtreecommitdiffhomepage
path: root/Storage.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-09-14 15:58:04 -0400
committerJoey Hess <joeyh@joeyh.name>2016-09-14 15:58:04 -0400
commita68caf8b54b9d37deeaeddc6a28394d1587f1dc5 (patch)
treefea62c654da0db4842da833dea71ffe1fd6684bc /Storage.hs
parent92f0a9c8b6c676281dcbee6e4bce938b969ef7c2 (diff)
downloadkeysafe-a68caf8b54b9d37deeaeddc6a28394d1587f1dc5.tar.gz
use multiple threads for chaffing
Diffstat (limited to 'Storage.hs')
-rw-r--r--Storage.hs13
1 files changed, 7 insertions, 6 deletions
diff --git a/Storage.hs b/Storage.hs
index 6115f30..b922501 100644
--- a/Storage.hs
+++ b/Storage.hs
@@ -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