parent
42af6afb86
commit
c37fe88b35
|
@ -94,10 +94,12 @@ import Debug.Trace (trace)
|
||||||
-- ToDo: load persisted state, thus this function already operates in IO
|
-- ToDo: load persisted state, thus this function already operates in IO
|
||||||
fediChordInit :: FediChordConf -> IO (Socket, LocalNodeStateSTM)
|
fediChordInit :: FediChordConf -> IO (Socket, LocalNodeStateSTM)
|
||||||
fediChordInit initConf = do
|
fediChordInit initConf = do
|
||||||
|
emptyLookupCache <- newTVarIO Map.empty
|
||||||
let realNode = RealNode {
|
let realNode = RealNode {
|
||||||
vservers = []
|
vservers = []
|
||||||
, nodeConfig = initConf
|
, nodeConfig = initConf
|
||||||
, bootstrapNodes = confBootstrapNodes initConf
|
, bootstrapNodes = confBootstrapNodes initConf
|
||||||
|
, lookupCacheSTM = emptyLookupCache
|
||||||
}
|
}
|
||||||
realNodeSTM <- newTVarIO realNode
|
realNodeSTM <- newTVarIO realNode
|
||||||
initialState <- nodeStateInit realNodeSTM
|
initialState <- nodeStateInit realNodeSTM
|
||||||
|
|
|
@ -145,6 +145,8 @@ data RealNode = RealNode
|
||||||
-- ^ holds the initial configuration read at program start
|
-- ^ 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
|
-- ^ nodes to be used as bootstrapping points, new ones learned during operation
|
||||||
|
, lookupCacheSTM :: TVar LookupCache
|
||||||
|
-- ^ a global cache of looked up keys and their associated nodes
|
||||||
}
|
}
|
||||||
|
|
||||||
type RealNodeSTM = TVar RealNode
|
type RealNodeSTM = TVar RealNode
|
||||||
|
@ -294,6 +296,9 @@ instance HasKeyID NodeID where
|
||||||
type NodeCacheEntry = CacheEntry RemoteNodeState
|
type NodeCacheEntry = CacheEntry RemoteNodeState
|
||||||
type NodeCache = RingMap NodeCacheEntry
|
type NodeCache = RingMap NodeCacheEntry
|
||||||
|
|
||||||
|
type LookupCacheEntry = CacheEntry (String, PortNumber)
|
||||||
|
type LookupCache = Map.Map NodeID LookupCacheEntry
|
||||||
|
|
||||||
-- | generic data structure for holding elements with a key and modular lookup
|
-- | generic data structure for holding elements with a key and modular lookup
|
||||||
newtype RingMap a = RingMap { getRingMap :: HasKeyID a => Map.Map NodeID (RingEntry a) }
|
newtype RingMap a = RingMap { getRingMap :: HasKeyID a => Map.Map NodeID (RingEntry a) }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue