parent
							
								
									e06c53ff7c
								
							
						
					
					
						commit
						bdb92411c6
					
				
					 2 changed files with 9 additions and 6 deletions
				
			
		|  | @ -501,11 +501,15 @@ requestQueryID :: LocalNodeState        -- ^ NodeState of the querying node | ||||||
| -- TODO: deal with lookup failures | -- TODO: deal with lookup failures | ||||||
| requestQueryID ns targetID = do | requestQueryID ns targetID = do | ||||||
|     firstCacheSnapshot <- readTVarIO . nodeCacheSTM $ ns |     firstCacheSnapshot <- readTVarIO . nodeCacheSTM $ ns | ||||||
|     queryIdLookupLoop firstCacheSnapshot ns targetID |     -- TODO: make maxAttempts configurable | ||||||
|  |     queryIdLookupLoop firstCacheSnapshot ns 50 targetID | ||||||
| 
 | 
 | ||||||
| -- | like 'requestQueryID, but allows passing of a custom cache, e.g. for joining | -- | like 'requestQueryID, but allows passing of a custom cache, e.g. for joining | ||||||
| queryIdLookupLoop :: NodeCache -> LocalNodeState -> NodeID -> IO RemoteNodeState | queryIdLookupLoop :: NodeCache -> LocalNodeState -> Int -> NodeID -> IO RemoteNodeState | ||||||
| queryIdLookupLoop cacheSnapshot ns targetID = do | -- return node itself as default fallback value against infinite recursion. | ||||||
|  | -- TODO: consider using an Either instead of a default value | ||||||
|  | queryIdLookupLoop _ ns 0 _ = pure $ toRemoteNodeState ns | ||||||
|  | queryIdLookupLoop cacheSnapshot ns maxAttempts targetID = do | ||||||
|     let localResult = queryLocalCache ns cacheSnapshot (lNumBestNodes ns) targetID |     let localResult = queryLocalCache ns cacheSnapshot (lNumBestNodes ns) targetID | ||||||
|     -- FOUND can only be returned if targetID is owned by local node |     -- FOUND can only be returned if targetID is owned by local node | ||||||
|     case localResult of |     case localResult of | ||||||
|  | @ -522,8 +526,7 @@ queryIdLookupLoop cacheSnapshot ns targetID = do | ||||||
|                     addCacheEntryPure now |                     addCacheEntryPure now | ||||||
|                               ) cacheSnapshot entrySet |                               ) cacheSnapshot entrySet | ||||||
|               in |               in | ||||||
|           -- TODO: this could lead to infinite recursion on an empty cache. Consider returning the node itself as default value |               queryIdLookupLoop newLCache ns (maxAttempts - 1) targetID | ||||||
|               queryIdLookupLoop newLCache ns targetID |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| sendQueryIdMessages :: (Integral i) | sendQueryIdMessages :: (Integral i) | ||||||
|  |  | ||||||
|  | @ -165,7 +165,7 @@ fediChordJoin cacheSnapshot nsSTM = do | ||||||
|     ns <- readTVarIO nsSTM |     ns <- readTVarIO nsSTM | ||||||
|     -- get routed to the currently responsible node, based on the response |     -- get routed to the currently responsible node, based on the response | ||||||
|     -- from the bootstrapping node |     -- from the bootstrapping node | ||||||
|     currentlyResponsible <- queryIdLookupLoop cacheSnapshot ns $ getNid ns |     currentlyResponsible <- queryIdLookupLoop cacheSnapshot ns 50 $ getNid ns | ||||||
|     -- 2. then send a join to the currently responsible node |     -- 2. then send a join to the currently responsible node | ||||||
|     joinResult <- requestJoin currentlyResponsible nsSTM |     joinResult <- requestJoin currentlyResponsible nsSTM | ||||||
|     case joinResult of |     case joinResult of | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue