diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-06-21 21:15:29 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-06-21 21:15:29 +0200 |
commit | 5272ec45fe18e78456ee3e8827f8f9569a046e48 (patch) | |
tree | bdbefc3767d643482b28b3a60d335461a8a462e6 /ymir/mlmmj-expose.nix | |
parent | 02d5a0ca96f405a55a5a47236ba5951fbdfccbde (diff) | |
download | nixos-5272ec45fe18e78456ee3e8827f8f9569a046e48.tar nixos-5272ec45fe18e78456ee3e8827f8f9569a046e48.tar.gz nixos-5272ec45fe18e78456ee3e8827f8f9569a046e48.tar.bz2 nixos-5272ec45fe18e78456ee3e8827f8f9569a046e48.tar.xz nixos-5272ec45fe18e78456ee3e8827f8f9569a046e48.zip |
consistent hashing
Diffstat (limited to 'ymir/mlmmj-expose.nix')
-rw-r--r-- | ymir/mlmmj-expose.nix | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/ymir/mlmmj-expose.nix b/ymir/mlmmj-expose.nix index b3eab046..bcf3a872 100644 --- a/ymir/mlmmj-expose.nix +++ b/ymir/mlmmj-expose.nix | |||
@@ -41,7 +41,7 @@ let | |||
41 | setCurrentDirectory listDir | 41 | setCurrentDirectory listDir |
42 | identities <- getIdentities | 42 | identities <- getIdentities |
43 | subscribers <- getSubscribers | 43 | subscribers <- getSubscribers |
44 | let hashes = filter ((==) extension . snd) [((ident, sub), take len $ hash' (ident, sub)) | ident <- identities, sub <- subscribers] | 44 | let hashes = filter ((==) extension . snd) [((ident, sub), hash' (ident, sub)) | ident <- identities, sub <- subscribers] |
45 | case hashes of | 45 | case hashes of |
46 | [(_, recipient)] -> do | 46 | [(_, recipient)] -> do |
47 | getContents >>= writeFile "queue/exposed" | 47 | getContents >>= writeFile "queue/exposed" |
@@ -82,10 +82,10 @@ let | |||
82 | readDir dir = concat <$> (mapM (fmap lines . readFile) . map (dir </>) . filter (not . (`elem` [".", ".."]))=<< (getDirectoryContents dir)) | 82 | readDir dir = concat <$> (mapM (fmap lines . readFile) . map (dir </>) . filter (not . (`elem` [".", ".."]))=<< (getDirectoryContents dir)) |
83 | 83 | ||
84 | hash' :: Show a => a -> String | 84 | hash' :: Show a => a -> String |
85 | hash' = map toLower . show . (hash :: BS.ByteString -> Digest SHA256) . CBS.pack . map toLower . show | 85 | hash' = take len . map toLower . show . (hash :: BS.ByteString -> Digest SHA256) . CBS.pack . map toLower . show |
86 | 86 | ||
87 | len :: Int | 87 | len :: Int |
88 | len = 16 | 88 | len = 64 |
89 | ''; | 89 | ''; |
90 | buildCommand = '' | 90 | buildCommand = '' |
91 | mkdir -p $out/bin | 91 | mkdir -p $out/bin |