update responding neighbours and delete unresponding ones from cache

contributes to #44
This commit is contained in:
Trolli Schmittlauch 2020-06-24 02:48:41 +02:00
parent 16b46a8b0b
commit 81e346db4e
2 changed files with 5 additions and 2 deletions

View file

@ -527,6 +527,9 @@ requestStabilise ns neighbour = do
,maybe succAcc (++ succAcc) (stabiliseSuccessors <$> payload msg))
)
([],[]) 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
then Left "no neighbours returned"
else Right (responsePreds, responseSuccs)

View file

@ -217,8 +217,8 @@ stabiliseThread nsSTM = forever $ do
newNs = setPredecessors newPreds . setSuccessors newSuccs $ newerNsSnap
writeTVar nsSTM newNs
pure newNs
-- TODO: update successfully stabilised nodes in cache
-- delete unresponding nodes from cache as well
mapM_ (atomically . writeTQueue (cacheWriteQueue updatedNs) . deleteCacheEntry . getNid) allDeletes
-- try looking up additional neighbours if list too short
forM_ [(length $ predecessors updatedNs)..(kNeighbours updatedNs)] (\_ -> do