stylish run

k-choices
Trolli Schmittlauch 2020-09-21 02:23:06 +02:00
parent 1a7afed062
commit 499c90e63a
2 changed files with 12 additions and 15 deletions

View File

@ -69,12 +69,12 @@ import qualified Data.ByteString.UTF8 as BSU
import Data.Either (rights)
import Data.Foldable (foldr')
import Data.Functor.Identity
import Data.HashMap.Strict (HashMap)
import qualified Data.HashMap.Strict as HMap
import Data.IP (IPv6, fromHostAddress6,
toHostAddress6)
import Data.List ((\\))
import qualified Data.Map.Strict as Map
import qualified Data.HashMap.Strict as HMap
import Data.HashMap.Strict (HashMap)
import Data.Maybe (catMaybes, fromJust, fromMaybe,
isJust, isNothing, mapMaybe)
import qualified Data.Set as Set
@ -375,7 +375,7 @@ nodeCacheVerifyThread nodeSTM = forever $ do
node <- readTVar nodeSTM
case headMay (HMap.elems $ vservers node) of
-- wait until first VS is joined
Nothing -> retry
Nothing -> retry
Just vs' -> pure (node, vs')
let
maxEntryAge = confMaxNodeCacheAge $ nodeConfig node

View File

@ -69,10 +69,10 @@ import Control.Exception
import Data.Foldable (foldr')
import Data.Function (on)
import qualified Data.Hashable as Hashable
import Data.List (delete, nub, sortBy)
import qualified Data.Map.Strict as Map
import Data.HashMap.Strict (HashMap)
import qualified Data.HashMap.Strict as HMap
import Data.List (delete, nub, sortBy)
import qualified Data.Map.Strict as Map
import Data.Maybe (fromJust, fromMaybe, isJust,
isNothing, mapMaybe)
import qualified Data.Set as Set
@ -153,22 +153,19 @@ a `localCompare` b
-- Also contains shared data and config values.
-- TODO: more data structures for k-choices bookkeeping
data RealNode s = RealNode
{ vservers :: HashMap NodeID (LocalNodeStateSTM s)
{ vservers :: HashMap NodeID (LocalNodeStateSTM s)
-- ^ map of all active VServer node IDs to their node state
, nodeConfig :: FediChordConf
, nodeConfig :: FediChordConf
-- ^ holds the initial configuration read at program start
, bootstrapNodes :: [(String, PortNumber)]
, bootstrapNodes :: [(String, PortNumber)]
-- ^ nodes to be used as bootstrapping points, new ones learned during operation
, lookupCacheSTM :: TVar LookupCache
, lookupCacheSTM :: TVar LookupCache
-- ^ a global cache of looked up keys and their associated nodes
, globalNodeCacheSTM :: TVar NodeCache
, globalNodeCacheSTM :: TVar NodeCache
-- ^ EpiChord node cache with expiry times for nodes.
-- Shared between all vservers, each 'LocalNodeState' holds a reference to
-- the same TVar for avoiding unnecessary reads of parent node
, globalCacheWriteQueue :: TQueue (NodeCache -> NodeCache)
, globalCacheWriteQueue :: TQueue (NodeCache -> NodeCache)
-- ^ cache updates are not written directly to the 'globalNodeCacheSTM'
-- but queued and processed by a single thread
, nodeService :: s (RealNodeSTM s)
, nodeService :: s (RealNodeSTM s)
}
type RealNodeSTM s = TVar (RealNode s)