Skip to content

Commit

Permalink
Remove mempool methods from QueryM.Ogmios
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusbfs committed Feb 5, 2025
1 parent 5c601fe commit 14a6d9d
Show file tree
Hide file tree
Showing 11 changed files with 548 additions and 646 deletions.
14 changes: 6 additions & 8 deletions src/Contract/Backend/Ogmios/Mempool.purs
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,18 @@ import Ctl.Internal.QueryM.Ogmios
( MempoolSizeAndCapacity
, MempoolSnapshotAcquired
, MempoolTransaction(MempoolTransaction)
, acquireMempoolSnapshotCall
) as Ogmios
import Ctl.Internal.QueryM.OgmiosWebsocket.JsWebSocket (JsWebSocket)
import Ctl.Internal.QueryM.OgmiosWebsocket.Mempool
( mempoolSnapshotHasTxCall
, mempoolSnapshotNextTxCall
, mempoolSnapshotSizeAndCapacityCall
, releaseMempoolCall
)
import Ctl.Internal.QueryM.OgmiosWebsocket.Types
( ListenerSet
, OgmiosListeners
, acquireMempoolSnapshotCall
, listeners
, mempoolSnapshotHasTxCall
, mempoolSnapshotNextTxCall
, mempoolSnapshotSizeAndCapacityCall
, mkRequestAff
, releaseMempoolCall
, underlyingWebSocket
)
import Data.Array as Array
Expand Down Expand Up @@ -118,7 +116,7 @@ acquireMempoolSnapshotFetch
:: QueryM Ogmios.MempoolSnapshotAcquired
acquireMempoolSnapshotFetch =
mkOgmiosRequest
Ogmios.acquireMempoolSnapshotCall
acquireMempoolSnapshotCall
_.acquireMempool
unit

Expand Down
4 changes: 2 additions & 2 deletions src/Internal/Contract/Monad.purs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ import Ctl.Internal.QueryM.OgmiosHttp
, getSystemStartTime
)
import Ctl.Internal.QueryM.OgmiosWebsocket.JsWebSocket (_wsClose, _wsFinalize)
import Ctl.Internal.QueryM.OgmiosWebsocket.Queries (QueryEnv)
import Ctl.Internal.QueryM.OgmiosWebsocket.Types
import Ctl.Internal.QueryM.OgmiosWebsocket.Mempool
( WebSocket
, mkOgmiosWebSocketAff
, underlyingWebSocket
)
import Ctl.Internal.QueryM.OgmiosWebsocket.Queries (QueryEnv)
import Ctl.Internal.Service.Blockfrost
( BlockfrostServiceM
, runBlockfrostServiceM
Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Contract/ProviderBackend.purs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module Ctl.Internal.Contract.ProviderBackend

import Prelude

import Ctl.Internal.QueryM.OgmiosWebsocket.Types (OgmiosWebSocket)
import Ctl.Internal.QueryM.OgmiosWebsocket.Mempool (OgmiosWebSocket)
import Ctl.Internal.ServerConfig (ServerConfig)
import Data.Maybe (Maybe(Just, Nothing))
import Data.Time.Duration (Seconds(Seconds))
Expand Down
4 changes: 2 additions & 2 deletions src/Internal/QueryM.purs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ import Ctl.Internal.Helpers (logWithLevel)
import Ctl.Internal.Logging (mkLogger)
import Ctl.Internal.QueryM.Ogmios (AdditionalUtxoSet, OgmiosTxEvaluationR)
import Ctl.Internal.QueryM.Ogmios as Ogmios
import Ctl.Internal.QueryM.OgmiosWebsocket.Queries (QueryEnv)
import Ctl.Internal.QueryM.OgmiosWebsocket.Types
import Ctl.Internal.QueryM.OgmiosWebsocket.Mempool
( listeners
, mkRequestAff
, underlyingWebSocket
)
import Ctl.Internal.QueryM.OgmiosWebsocket.Queries (QueryEnv)
import Data.Bifunctor (lmap)
import Data.Either (Either(Left, Right))
import Data.Maybe (fromMaybe)
Expand Down
2 changes: 1 addition & 1 deletion src/Internal/QueryM/CurrentEpoch.purs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Effect.Exception (error)
-- | Get the current Epoch. Details can be found https://ogmios.dev/api/ under
-- | "currentEpoch" query
getCurrentEpoch :: QueryM CurrentEpoch
getCurrentEpoch = do
getCurrentEpoch = do
resp <- OgmiosHttp.currentEpoch
case resp of
Left err -> throwError $ error $ pprintOgmiosDecodeError err
Expand Down
45 changes: 0 additions & 45 deletions src/Internal/QueryM/Ogmios.purs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,7 @@ module Ctl.Internal.QueryM.Ogmios
, OgmiosTxEvaluationR(OgmiosTxEvaluationR)
, aesonObject
, aesonArray
, acquireMempoolSnapshotCall
, evaluateTxCall
, mempoolSnapshotHasTxCall
, mempoolSnapshotNextTxCall
, mempoolSnapshotSizeAndCapacityCall
, mkOgmiosCallType
, mkOgmiosCallTypeNoArgs
, releaseMempoolCall
, submitSuccessPartialResp
, parseIpv6String
, rationalToSubcoin
Expand Down Expand Up @@ -202,48 +195,10 @@ evaluateTxCall = mkOgmiosCallType
}
}

--------------------------------------------------------------------------------
-- Local Tx Monitor Protocol
-- https://ogmios.dev/mini-protocols/local-tx-monitor/
--------------------------------------------------------------------------------

acquireMempoolSnapshotCall :: JsonRpc2Call Unit MempoolSnapshotAcquired
acquireMempoolSnapshotCall =
mkOgmiosCallTypeNoArgs "acquireMempool"

mempoolSnapshotHasTxCall
:: MempoolSnapshotAcquired -> JsonRpc2Call TransactionHash HasTxR
mempoolSnapshotHasTxCall _ = mkOgmiosCallType
{ method: "hasTransaction"
, params: { id: _ }
}

mempoolSnapshotNextTxCall
:: MempoolSnapshotAcquired -> JsonRpc2Call Unit MaybeMempoolTransaction
mempoolSnapshotNextTxCall _ = mkOgmiosCallType
{ method: "nextTransaction"
, params: const { fields: "all" }
}

mempoolSnapshotSizeAndCapacityCall
:: MempoolSnapshotAcquired -> JsonRpc2Call Unit MempoolSizeAndCapacity
mempoolSnapshotSizeAndCapacityCall _ =
mkOgmiosCallTypeNoArgs "sizeOfMempool"

releaseMempoolCall
:: MempoolSnapshotAcquired -> JsonRpc2Call Unit ReleasedMempool
releaseMempoolCall _ =
mkOgmiosCallTypeNoArgs "releaseMempool"

--------------------------------------------------------------------------------
-- Helpers
--------------------------------------------------------------------------------

mkOgmiosCallTypeNoArgs
:: forall (o :: Type). DecodeOgmios o => String -> JsonRpc2Call Unit o
mkOgmiosCallTypeNoArgs method =
mkOgmiosCallType { method, params: const {} }

mkOgmiosCallType
:: forall (a :: Type) (i :: Type) (o :: Type)
. EncodeAeson (JsonRpc2Request a)
Expand Down
15 changes: 9 additions & 6 deletions src/Internal/QueryM/OgmiosHttp.purs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ import Affjax.ResponseFormat (string) as Affjax.ResponseFormat
import Affjax.StatusCode (StatusCode(StatusCode))
import Affjax.StatusCode as Affjax.StatusCode
import Cardano.AsCbor (encodeCbor)
import Cardano.Provider.Error (ClientError(..), ServiceError(..))
import Cardano.Provider.Error
( ClientError(ClientHttpError, ClientHttpResponseError)
, ServiceError(ServiceOtherError)
)
import Cardano.Provider.TxEvaluation as Provider
import Cardano.Serialization.Lib (fromBytes)
import Cardano.Types
Expand All @@ -56,10 +59,10 @@ import Cardano.Types.Chain as Chain
import Cardano.Types.Coin (Coin(Coin))
import Cardano.Types.CostModel (CostModel(CostModel))
import Cardano.Types.EraSummaries
( EraSummaries(..)
, EraSummary(..)
, EraSummaryParameters(..)
, EraSummaryTime(..)
( EraSummaries(EraSummaries)
, EraSummary(EraSummary)
, EraSummaryParameters(EraSummaryParameters)
, EraSummaryTime(EraSummaryTime)
)
import Cardano.Types.ExUnitPrices (ExUnitPrices(ExUnitPrices))
import Cardano.Types.ExUnits (ExUnits(ExUnits))
Expand Down Expand Up @@ -93,7 +96,7 @@ import Ctl.Internal.Helpers (encodeMap, showWithParens)
import Ctl.Internal.QueryM (QueryM)
import Ctl.Internal.QueryM.JsonRpc2
( class DecodeOgmios
, OgmiosDecodeError(..)
, OgmiosDecodeError(ClientErrorResponse, ResultDecodingError)
, OgmiosError
, decodeErrorOrResult
, decodeOgmios
Expand Down
Loading

0 comments on commit 14a6d9d

Please sign in to comment.