use global cache adding function
This commit is contained in:
parent
e3bfa26ddb
commit
ad1465c5fe
|
@ -203,14 +203,14 @@ queryIdLookupLoop cacheSnapshot ns targetID = do
|
|||
now <- getPOSIXTime
|
||||
newLCache <- foldM (\oldCache resp -> do
|
||||
let entriesToInsert = case queryResult <$> payload resp of
|
||||
Just (FOUND result1) -> [addCacheEntryPure now (RemoteCacheEntry result1 now)]
|
||||
Just (FORWARD resultset) -> addCacheEntryPure now <$> Set.elems resultset
|
||||
Just (FOUND result1) -> [RemoteCacheEntry result1 now]
|
||||
Just (FORWARD resultset) -> Set.elems resultset
|
||||
_ -> []
|
||||
-- forward entries to global cache
|
||||
forM_ entriesToInsert $ \entry -> atomically $ writeTQueue (cacheWriteQueue ns) entry
|
||||
queueAddEntries entriesToInsert ns
|
||||
-- insert entries into local cache copy
|
||||
pure $ foldl' (
|
||||
\oldLCache insertFunc -> insertFunc oldLCache
|
||||
pure $ foldr' (
|
||||
addCacheEntryPure now
|
||||
) oldCache entriesToInsert
|
||||
) cacheSnapshot responses
|
||||
|
||||
|
@ -283,7 +283,7 @@ sendRequestTo timeoutMillis numAttempts msgIncomplete sock = do
|
|||
|
||||
|
||||
-- | enqueue a list of RemoteCacheEntries to be added to the global NodeCache
|
||||
queueAddEntries :: [RemoteCacheEntry]
|
||||
queueAddEntries :: Foldable c => c RemoteCacheEntry
|
||||
-> LocalNodeState
|
||||
-> IO ()
|
||||
queueAddEntries entries ns = do
|
||||
|
|
Loading…
Reference in a new issue