A peer-to-peer stack for code collaboration
Log machine updates from pubsub
Thomas Scholtesff10298500fd
diff --git a/exe/Daemon.hs b/exe/Daemon.hsindex 16d62c1..c5d86cc 100644--- a/exe/Daemon.hs+++ b/exe/Daemon.hs@@ -230,10 +230,7 @@ send id (Api.SendRequest expressions) = docase machineMode ofReader -> requestInput machineSubscriptionWriter -> do- logInfo "Applying input"- [ ("machine-id", getMachineId id)- ]- results <- writeInputs id expressions Nothing+ results <- writeInputs "http" id expressions Nothingpure Api.SendResponse{..}wherematchMessage nonce = \case@@ -411,7 +408,7 @@ actAsWriter m = dowhereid = machineId monMsg = \case- Submit SubmitInputs{..} -> writeInputs id expressions (Just nonce) >> pure ()+ Submit SubmitInputs{..} -> writeInputs "pubsub" id expressions (Just nonce) >> pure ()_ -> pure ()-- | Installs a handler for messages sent on the machine's IPFS pubsub channel.@@ -432,8 +429,11 @@ installMachineMessageHandler m handleMessage = do---- Sends out a 'InputsApplied' message over pubsub that includes the-- outputs and the given nonce.-writeInputs :: MachineId -> [Value] -> Maybe Text -> Daemon [Value]-writeInputs id inputs nonce = do+--+-- @source@ is the source of the inputs (either HTTP or pubsub) and is+-- only used for logging.+writeInputs :: Text -> MachineId -> [Value] -> Maybe Text -> Daemon [Value]+writeInputs source id inputs nonce = do(rs, idx) <- modifyMachine id $ \machine -> do-- We check that the new inputs are valid before writing them to IPFS.(newState, results) <- runInputs machine inputs@@ -442,9 +442,10 @@ writeInputs id inputs nonce = domachineIpfs id $ publish id (New InputsApplied{results, nonce})pure (machine', (results, machineLastIndex machine'))writeMachineConfig- logDebug "Wrote inputs to IPFS"+ logInfo "Updated machine"[ ("machine-id", getMachineId id), ("new-input-index", show idx)+ , ("source", source)]pure rs