diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-09-26 14:11:32 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-09-26 14:15:52 -0400 |
commit | a1d5de397cd1b12080e4652965591827e6d50c86 (patch) | |
tree | b2385eb31dba6e130cd2af2bd6b298cb0bc7bc0f /Storage.hs | |
parent | 2c6a13f5db2671038efbfdcdb9c63f4758bd2e18 (diff) | |
download | keysafe-a1d5de397cd1b12080e4652965591827e6d50c86.tar.gz |
Randomize the server list.
May help avoid some correlations. Once there are many servers, will spread
the load out amoung them.
This commit was sponsored by Ethan Aubin.
Diffstat (limited to 'Storage.hs')
-rw-r--r-- | Storage.hs | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -29,9 +29,9 @@ import Control.Concurrent.Async import qualified Data.Set as S import Network.Wai.Handler.Warp (Port) -networkStorageLocations :: Maybe LocalStorageDirectory -> StorageLocations -networkStorageLocations d = StorageLocations $ - map (networkStorage d) networkServers +networkStorageLocations :: Maybe LocalStorageDirectory -> IO StorageLocations +networkStorageLocations d = StorageLocations . map (networkStorage d) + <$> shuffleServers networkServers localStorageLocations :: Maybe LocalStorageDirectory -> StorageLocations localStorageLocations d = StorageLocations $ @@ -125,12 +125,12 @@ retrieveShares (StorageLocations locs) sis updateprogress = do -- | Returns descriptions of any failures. tryUploadQueued :: Maybe LocalStorageDirectory -> IO [String] tryUploadQueued d = do + StorageLocations locs <- networkStorageLocations d results <- forM locs $ \loc -> case uploadQueue loc of Nothing -> return [] Just q -> moveShares q loc return $ processresults (concat results) [] where - StorageLocations locs = networkStorageLocations d processresults [] c = nub c processresults (StoreSuccess:rs) c = processresults rs c processresults (StoreFailure e:rs) c = processresults rs (e:c) @@ -152,7 +152,7 @@ storeChaff hn port delayseconds = forever $ do [1..totalObjects (shareParams testModeTunables)] where server = networkStorage Nothing $ - Server (ServerName hn) Untrusted [ServerAddress hn port] + Server (ServerName hn) Untrusted [ServerAddress hn port] "chaff server" objsize = objectSize defaultTunables * shareOverhead defaultTunables maxmsdelay = ceiling $ 1000000 * fromMaybe 0 delayseconds go sis rng n = do |