parent
111c1a299d
commit
25f44f3a45
|
@ -217,15 +217,30 @@ stabiliseThread nsSTM = forever $ do
|
||||||
-- TODO: update successfully stabilised nodes in cache
|
-- TODO: update successfully stabilised nodes in cache
|
||||||
|
|
||||||
-- try looking up additional neighbours if list too short
|
-- try looking up additional neighbours if list too short
|
||||||
|
forM_ [(length $ predecessors updatedNs)..(kNeighbours updatedNs)] (\_ -> do
|
||||||
|
ns' <- readTVarIO nsSTM
|
||||||
|
nextEntry <- requestQueryID ns' $ pred . getNid $ atDef (toRemoteNodeState ns') (predecessors ns') (-1)
|
||||||
|
atomically $ do
|
||||||
|
latestNs <- readTVar nsSTM
|
||||||
|
writeTVar nsSTM $ addPredecessors [nextEntry] latestNs
|
||||||
|
)
|
||||||
|
--
|
||||||
|
forM_ [(length $ successors updatedNs)..(kNeighbours updatedNs)] (\_ -> do
|
||||||
|
ns' <- readTVarIO nsSTM
|
||||||
|
nextEntry <- requestQueryID ns' $ succ . getNid $ atDef (toRemoteNodeState ns') (successors ns') (-1)
|
||||||
|
atomically $ do
|
||||||
|
latestNs <- readTVar nsSTM
|
||||||
|
writeTVar nsSTM $ addSuccessors [nextEntry] latestNs
|
||||||
|
)
|
||||||
|
|
||||||
-- TODO: make delay configurable
|
-- TODO: make delay configurable
|
||||||
threadDelay (60 * 1000)
|
threadDelay (60 * 1000)
|
||||||
where
|
where
|
||||||
stabiliseClosestResponder :: LocalNodeState
|
stabiliseClosestResponder :: LocalNodeState
|
||||||
-> (LocalNodeState -> [RemoteNodeState])
|
-> (LocalNodeState -> [RemoteNodeState])
|
||||||
-> Int
|
-> Int
|
||||||
-> [RemoteNodeState] -- ^ delete accumulator
|
-> [RemoteNodeState] -- ^ delete accumulator
|
||||||
-> IO (Either String ([RemoteNodeState], [RemoteNodeState])) -- ^ (nodes to be deleted, successfully pinged potential neighbours)
|
-> IO (Either String ([RemoteNodeState], [RemoteNodeState])) -- ^ (nodes to be deleted, successfully pinged potential neighbours)
|
||||||
stabiliseClosestResponder ns neighbourGetter neighbourNum deleteAcc
|
stabiliseClosestResponder ns neighbourGetter neighbourNum deleteAcc
|
||||||
| isNothing (currentNeighbour ns neighbourGetter neighbourNum) = pure $ Left "exhausted all neigbours"
|
| isNothing (currentNeighbour ns neighbourGetter neighbourNum) = pure $ Left "exhausted all neigbours"
|
||||||
| otherwise = do
|
| otherwise = do
|
||||||
|
|
Loading…
Reference in a new issue