Skip to content

Commit

Permalink
Warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mueller committed May 11, 2021
1 parent 9766a78 commit c20a573
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
2 changes: 1 addition & 1 deletion plutus-pab/src/Plutus/PAB/App.hs
Expand Up @@ -85,7 +85,7 @@ appEffectHandlers config trace =
env <- liftIO $ mkEnv trace config
let Config{nodeServerConfig=MockServerConfig{mscSocketPath, mscSlotConfig}} = config
instancesState <- liftIO $ STM.atomically $ Instances.emptyInstancesState
blockchainEnv <- liftIO $ BlockchainEnv.startNodeClient mscSocketPath mscSlotConfig instancesState
blockchainEnv <- liftIO $ BlockchainEnv.startNodeClient mscSocketPath mscSlotConfig
pure (instancesState, blockchainEnv, env)

, handleLogMessages =
Expand Down
17 changes: 2 additions & 15 deletions plutus-pab/src/Plutus/PAB/Core/ContractInstance/BlockchainEnv.hs
Expand Up @@ -20,15 +20,13 @@ import Plutus.PAB.Core.ContractInstance.STM (BlockchainEnv (..), Insta
import qualified Plutus.PAB.Core.ContractInstance.STM as S

import Cardano.Node.Types (SlotConfig)
import Control.Concurrent (forkIO)
import Control.Concurrent.STM (STM)
import qualified Control.Concurrent.STM as STM
import Control.Lens
import Control.Monad (guard, unless, when)
import Control.Monad (unless, when)
import Data.Foldable (foldl')
import Data.Map (Map)
import Data.Set (Set)
import qualified Data.Set as Set
import Wallet.Emulator.ChainIndex.Index (ChainIndex, ChainIndexItem (..))
import qualified Wallet.Emulator.ChainIndex.Index as Index

Expand All @@ -37,9 +35,8 @@ import qualified Wallet.Emulator.ChainIndex.Index as Index
startNodeClient ::
FilePath -- ^ Socket to connect to node
-> SlotConfig -- ^ Slot config used by the node
-> InstancesState
-> IO BlockchainEnv
startNodeClient socket slotConfig instancesState = do
startNodeClient socket slotConfig = do
env <- STM.atomically emptyBlockchainEnv
_ <- Client.runClientNode socket slotConfig $ \block slot -> do
STM.atomically $ processBlock env block slot
Expand All @@ -49,22 +46,12 @@ startNodeClient socket slotConfig instancesState = do
-- active instances.
data ClientEnv = ClientEnv{ceAddresses :: Set Address, ceTransactions :: Set TxId} deriving Eq

initialClientEnv :: ClientEnv
initialClientEnv = ClientEnv mempty mempty

getClientEnv :: InstancesState -> STM ClientEnv
getClientEnv instancesState =
ClientEnv
<$> S.watchedAddresses instancesState
<*> S.watchedTransactions instancesState

-- | Wait until the 'ClientEnv' has changed.
nextClientEnv :: InstancesState -> ClientEnv -> STM ClientEnv
nextClientEnv instancesState currentEnv = do
newEnv <- getClientEnv instancesState
guard $ newEnv /= currentEnv
pure newEnv

-- | Go through the transactions in a block, updating the 'BlockchainEnv'
-- when any interesting addresses or transactions have changed.
processBlock :: BlockchainEnv -> Block -> Slot -> STM ()
Expand Down
2 changes: 1 addition & 1 deletion plutus-pab/src/Plutus/PAB/Monitoring/Util.hs
Expand Up @@ -142,7 +142,7 @@ newtype PrettyObject t = PrettyObject { unPrettyObject :: t }
deriving newtype (ToJSON, FromJSON)

instance (Pretty t) => ToObject (PrettyObject t) where
toObject v (PrettyObject t) =
toObject _ (PrettyObject t) =
let str = Text.toStrict . Render.renderLazy . layoutPretty defaultLayoutOptions $ pretty t in
HM.singleton "string" (toJSON str)
textTransformer (PrettyObject t) _ = Text.toStrict . Render.renderLazy . layoutPretty defaultLayoutOptions $ pretty t

0 comments on commit c20a573

Please sign in to comment.