From 12b22db629cd50b46cbdcb7057c692983cfb3796 Mon Sep 17 00:00:00 2001 From: Szabo Gergely Date: Tue, 22 Feb 2022 11:09:43 +0100 Subject: [PATCH] Add tip polling interval configuration --- README.md | 2 ++ examples/plutus-game/app/Main.hs | 1 + examples/plutus-nft/app/Main.hs | 1 + examples/plutus-transfer/app/Main.hs | 1 + src/BotPlutusInterface/Contract.hs | 2 +- src/BotPlutusInterface/Types.hs | 3 +++ 6 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 16293e0f..93db79ee 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,7 @@ main = do , pcChainIndexUrl = BaseUrl Http "localhost" 9083 "" , pcPort = 9080 , pcProtocolParams = protocolParams + , pcTipPollingInterval = 10_000_000 , -- | Slot configuration of the network, the default value can be used for the mainnet pcSlotConfig = def , pcOwnPubKeyHash = "0f45aaf1b2959db6e5ff94dbb1f823bf257680c3c723ac2d49f97546" @@ -97,6 +98,7 @@ main = do , pcLogLevel = Debug , -- Protocol params file location relative to the cardano-cli working directory (needed for the cli) , pcProtocolParamsFile = "./protocol.json" + , pcEnableTxEndpoint = True } BotPlutusInterface.runPAB @MyContracts pabConf ``` diff --git a/examples/plutus-game/app/Main.hs b/examples/plutus-game/app/Main.hs index 8b39b5dd..b2be8360 100644 --- a/examples/plutus-game/app/Main.hs +++ b/examples/plutus-game/app/Main.hs @@ -58,6 +58,7 @@ main = do , pcChainIndexUrl = BaseUrl Http "localhost" 9083 "" , pcPort = 9080 , pcProtocolParams = protocolParams + , pcTipPollingInterval = 10_000_000 , pcSlotConfig = def , pcOwnPubKeyHash = "0f45aaf1b2959db6e5ff94dbb1f823bf257680c3c723ac2d49f97546" , pcScriptFileDir = "./scripts" diff --git a/examples/plutus-nft/app/Main.hs b/examples/plutus-nft/app/Main.hs index 5d58435c..2ab74c23 100644 --- a/examples/plutus-nft/app/Main.hs +++ b/examples/plutus-nft/app/Main.hs @@ -58,6 +58,7 @@ main = do , pcChainIndexUrl = BaseUrl Http "localhost" 9083 "" , pcPort = 9080 , pcProtocolParams = protocolParams + , pcTipPollingInterval = 10_000_000 , pcSlotConfig = def , pcOwnPubKeyHash = "0f45aaf1b2959db6e5ff94dbb1f823bf257680c3c723ac2d49f97546" , pcScriptFileDir = "./scripts" diff --git a/examples/plutus-transfer/app/Main.hs b/examples/plutus-transfer/app/Main.hs index b4f0c729..eeb46645 100644 --- a/examples/plutus-transfer/app/Main.hs +++ b/examples/plutus-transfer/app/Main.hs @@ -57,6 +57,7 @@ main = do , pcChainIndexUrl = BaseUrl Http "localhost" 9083 "" , pcPort = 9080 , pcProtocolParams = protocolParams + , pcTipPollingInterval = 10_000_000 , pcSlotConfig = def , pcOwnPubKeyHash = "0f45aaf1b2959db6e5ff94dbb1f823bf257680c3c723ac2d49f97546" , pcScriptFileDir = "./scripts" diff --git a/src/BotPlutusInterface/Contract.hs b/src/BotPlutusInterface/Contract.hs index b036eb31..885dce33 100644 --- a/src/BotPlutusInterface/Contract.hs +++ b/src/BotPlutusInterface/Contract.hs @@ -228,7 +228,7 @@ awaitSlot :: Slot -> Eff effs Slot awaitSlot contractEnv s@(Slot n) = do - threadDelay @w 10_000_000 + threadDelay @w (fromIntegral contractEnv.cePABConfig.pcTipPollingInterval) tip <- CardanoCLI.queryTip @w contractEnv.cePABConfig case tip of Right tip' diff --git a/src/BotPlutusInterface/Types.hs b/src/BotPlutusInterface/Types.hs index 756a0217..44fd896e 100644 --- a/src/BotPlutusInterface/Types.hs +++ b/src/BotPlutusInterface/Types.hs @@ -31,6 +31,7 @@ import GHC.Generics (Generic) import Ledger (PubKeyHash) import Ledger.TimeSlot (SlotConfig) import Network.Wai.Handler.Warp (Port) +import Numeric.Natural (Natural) import Plutus.PAB.Core.ContractInstance.STM (Activity) import Plutus.PAB.Effects.Contract.Builtin ( HasDefinitions (..), @@ -61,6 +62,7 @@ data PABConfig = PABConfig pcDryRun :: !Bool , pcLogLevel :: !LogLevel , pcOwnPubKeyHash :: !PubKeyHash + , pcTipPollingInterval :: !Natural , pcPort :: !Port , pcEnableTxEndpoint :: !Bool } @@ -115,6 +117,7 @@ instance Default PABConfig where , pcNetwork = Testnet (NetworkMagic 42) , pcProtocolParams = def , pcSlotConfig = def + , pcTipPollingInterval = 10_000_000 , pcScriptFileDir = "./result-scripts" , pcSigningKeyFileDir = "./signing-keys" , pcTxFileDir = "./txs"