Skip to content

Commit

Permalink
Use connectToLocalNodeWithVersion always
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Jul 27, 2021
1 parent f60f233 commit 2e86092
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
31 changes: 17 additions & 14 deletions cardano-api/src/Cardano/Api/IPC.hs
Expand Up @@ -483,13 +483,14 @@ queryNodeLocalState :: forall mode result.
-> IO (Either Net.Query.AcquireFailure result)
queryNodeLocalState connctInfo mpoint query = do
resultVar <- newEmptyTMVarIO
connectToLocalNode
connectToLocalNodeWithVersion
connctInfo
LocalNodeClientProtocols {
localChainSyncClient = NoLocalChainSyncClient,
localStateQueryClient = Just (singleQuery mpoint resultVar),
localTxSubmissionClient = Nothing
}
( \_ntcVersion -> LocalNodeClientProtocols
{ localChainSyncClient = NoLocalChainSyncClient
, localStateQueryClient = Just (singleQuery mpoint resultVar)
, localTxSubmissionClient = Nothing
}
)
atomically (takeTMVar resultVar)
where
singleQuery
Expand Down Expand Up @@ -522,13 +523,14 @@ submitTxToNodeLocal :: forall mode.
-> IO (Net.Tx.SubmitResult (TxValidationErrorInMode mode))
submitTxToNodeLocal connctInfo tx = do
resultVar <- newEmptyTMVarIO
connectToLocalNode
connectToLocalNodeWithVersion
connctInfo
LocalNodeClientProtocols {
localChainSyncClient = NoLocalChainSyncClient,
localTxSubmissionClient = Just (localTxSubmissionClientSingle resultVar),
localStateQueryClient = Nothing
}
( \_ntcVersion -> LocalNodeClientProtocols
{ localChainSyncClient = NoLocalChainSyncClient
, localTxSubmissionClient = Just (localTxSubmissionClientSingle resultVar)
, localStateQueryClient = Nothing
}
)
atomically (takeTMVar resultVar)
where
localTxSubmissionClientSingle
Expand All @@ -550,13 +552,14 @@ submitTxToNodeLocal connctInfo tx = do
getLocalChainTip :: LocalNodeConnectInfo mode -> IO ChainTip
getLocalChainTip localNodeConInfo = do
resultVar <- newEmptyTMVarIO
connectToLocalNode
connectToLocalNodeWithVersion
localNodeConInfo
LocalNodeClientProtocols
( \_ntcVersion -> LocalNodeClientProtocols
{ localChainSyncClient = LocalChainSyncClient $ chainSyncGetCurrentTip resultVar
, localTxSubmissionClient = Nothing
, localStateQueryClient = Nothing
}
)
atomically $ takeTMVar resultVar

chainSyncGetCurrentTip
Expand Down
6 changes: 3 additions & 3 deletions cardano-api/src/Cardano/Api/LedgerState.hs
Expand Up @@ -63,7 +63,7 @@ import Cardano.Api.Eras
import Cardano.Api.IPC (ConsensusModeParams (CardanoModeParams), EpochSlots (..),
LocalChainSyncClient (LocalChainSyncClientPipelined),
LocalNodeClientProtocols (..), LocalNodeClientProtocolsInMode,
LocalNodeConnectInfo (..), connectToLocalNode)
LocalNodeConnectInfo (..), connectToLocalNodeWithVersion)
import Cardano.Api.Modes (CardanoMode)
import Cardano.Api.NetworkId (NetworkId)
import qualified Cardano.Chain.Genesis
Expand Down Expand Up @@ -242,9 +242,9 @@ foldBlocks nodeConfigFilePath socketPath networkId enableValidation state0 accum
stateIORef <- lift $ newIORef state0

-- Connect to the node.
lift $ connectToLocalNode
lift $ connectToLocalNodeWithVersion
connectInfo
(protocols stateIORef errorIORef env ledgerState)
(\_ntcVersion -> protocols stateIORef errorIORef env ledgerState)

lift (readIORef errorIORef) >>= \case
Just err -> throwE (FoldBlocksApplyBlockError err)
Expand Down
4 changes: 2 additions & 2 deletions cardano-client-demo/ScanBlocks.hs
Expand Up @@ -31,9 +31,9 @@ main = do

-- Connect to the node.
putStrLn $ "Connecting to socket: " <> socketPath
connectToLocalNode
connectToLocalNodeWithVersion
(connectInfo socketPath)
protocols
(\_ntcVersion -> protocols)
where
connectInfo :: FilePath -> LocalNodeConnectInfo CardanoMode
connectInfo socketPath =
Expand Down
4 changes: 2 additions & 2 deletions cardano-client-demo/ScanBlocksPipelined.hs
Expand Up @@ -40,9 +40,9 @@ main = do

-- Connect to the node.
putStrLn $ "Connecting to socket: " <> socketPath
connectToLocalNode
connectToLocalNodeWithVersion
(connectInfo socketPath)
protocols
(\_ntcVersion -> protocols)
where
connectInfo :: FilePath -> LocalNodeConnectInfo CardanoMode
connectInfo socketPath =
Expand Down

0 comments on commit 2e86092

Please sign in to comment.