forked from schmittlauch/Hash2Pub
update responding neighbours and delete unresponding ones from cache
contributes to #44
This commit is contained in:
parent
16b46a8b0b
commit
81e346db4e
|
@ -527,6 +527,9 @@ requestStabilise ns neighbour = do
|
||||||
,maybe succAcc (++ succAcc) (stabiliseSuccessors <$> payload msg))
|
,maybe succAcc (++ succAcc) (stabiliseSuccessors <$> payload msg))
|
||||||
)
|
)
|
||||||
([],[]) respSet
|
([],[]) respSet
|
||||||
|
-- update successfully responded neighbour in cache
|
||||||
|
now <- getPOSIXTime
|
||||||
|
maybe (pure ()) (\p -> queueAddEntries (Identity $ RemoteCacheEntry (sender p) now) ns) $ headMay (Set.elems respSet)
|
||||||
pure $ if null responsePreds && null responseSuccs
|
pure $ if null responsePreds && null responseSuccs
|
||||||
then Left "no neighbours returned"
|
then Left "no neighbours returned"
|
||||||
else Right (responsePreds, responseSuccs)
|
else Right (responsePreds, responseSuccs)
|
||||||
|
|
|
@ -217,8 +217,8 @@ stabiliseThread nsSTM = forever $ do
|
||||||
newNs = setPredecessors newPreds . setSuccessors newSuccs $ newerNsSnap
|
newNs = setPredecessors newPreds . setSuccessors newSuccs $ newerNsSnap
|
||||||
writeTVar nsSTM newNs
|
writeTVar nsSTM newNs
|
||||||
pure newNs
|
pure newNs
|
||||||
|
-- delete unresponding nodes from cache as well
|
||||||
-- TODO: update successfully stabilised nodes in cache
|
mapM_ (atomically . writeTQueue (cacheWriteQueue updatedNs) . deleteCacheEntry . getNid) allDeletes
|
||||||
|
|
||||||
-- 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
|
forM_ [(length $ predecessors updatedNs)..(kNeighbours updatedNs)] (\_ -> do
|
||||||
|
|
Loading…
Reference in a new issue