forked from schmittlauch/Hash2Pub
		
	add some debug output prints
This commit is contained in:
		
							parent
							
								
									2c827ea326
								
							
						
					
					
						commit
						4e359775ec
					
				
					 2 changed files with 7 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -213,6 +213,7 @@ handleIncomingRequest nsSTM sendQ msgSet sourceAddr = do
 | 
			
		|||
-- | execute a key ID lookup on local cache and respond with the result
 | 
			
		||||
respondQueryID :: LocalNodeStateSTM -> Set.Set FediChordMessage -> IO (Map.Map Integer BS.ByteString)
 | 
			
		||||
respondQueryID nsSTM msgSet = do
 | 
			
		||||
    putStrLn "responding to a QueryID request"
 | 
			
		||||
    -- this message cannot be split reasonably, so just
 | 
			
		||||
    -- consider the first payload
 | 
			
		||||
    let
 | 
			
		||||
| 
						 | 
				
			
			@ -487,7 +488,10 @@ sendRequestTo :: Int                    -- ^ timeout in seconds
 | 
			
		|||
sendRequestTo timeoutMillis numAttempts msgIncomplete sock = do
 | 
			
		||||
    -- give the message a random request ID
 | 
			
		||||
    randomID <- randomRIO (0, 2^32-1)
 | 
			
		||||
    let requests = serialiseMessage sendMessageSize $ msgIncomplete randomID
 | 
			
		||||
    let
 | 
			
		||||
        msgComplete = msgIncomplete randomID
 | 
			
		||||
        requests = serialiseMessage sendMessageSize msgComplete
 | 
			
		||||
    putStrLn $ "sending request message " <> show msgComplete
 | 
			
		||||
    -- create a queue for passing received response messages back, even after a timeout
 | 
			
		||||
    responseQ <- newTBQueueIO $ 2*maximumParts  -- keep room for duplicate packets
 | 
			
		||||
    -- start sendAndAck with timeout
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -128,6 +128,7 @@ fediChordBootstrapJoin :: LocalNodeStateSTM              -- ^ the local 'NodeSta
 | 
			
		|||
fediChordBootstrapJoin nsSTM (joinHost, joinPort) =
 | 
			
		||||
    -- can be invoked multiple times with all known bootstrapping nodes until successfully joined
 | 
			
		||||
    bracket (mkSendSocket joinHost joinPort) close (\sock -> do
 | 
			
		||||
        putStrLn "BootstrapJoin"
 | 
			
		||||
        -- 1. get routed to placement of own ID until FOUND:
 | 
			
		||||
        -- Initialise an empty cache only with the responses from a bootstrapping node
 | 
			
		||||
        ns <- readTVarIO nsSTM
 | 
			
		||||
| 
						 | 
				
			
			@ -145,6 +146,7 @@ fediChordBootstrapJoin nsSTM (joinHost, joinPort) =
 | 
			
		|||
                           Just (FORWARD resultset) -> foldr' (addCacheEntryPure now) cacheAcc resultset
 | 
			
		||||
                              )
 | 
			
		||||
                           initCache bootstrapResponse
 | 
			
		||||
               putStrLn "initialised bootstrap cache"
 | 
			
		||||
               fediChordJoin bootstrapCache nsSTM
 | 
			
		||||
                                                   )
 | 
			
		||||
       `catch` (\e -> pure . Left $ "Error at bootstrap joining: " <> displayException (e :: IOException))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue