Skip to content

Commit 4e69dad

Browse files
dmq: local message submission
1 parent ba60e40 commit 4e69dad

File tree

4 files changed

+118
-0
lines changed

4 files changed

+118
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{-# LANGUAGE DataKinds #-}
2+
3+
-- | A higher level API to implement clients for local message submission
4+
-- miniprotocol. This aliases the client from the 'LocalTxSubmission' protocol.
5+
--
6+
-- For execution, 'localMsgSubmissionClientPeer' reinterprets this high level
7+
-- description into the underlying typed protocol representation.
8+
--
9+
module DMQ.Protocol.LocalMsgSubmission.Client
10+
( -- * Client API types (re-exports)
11+
LocalMsgSubmissionClient
12+
, LocalMsgClientStIdle
13+
-- * Translates the client into a typed protocol
14+
, localMsgSubmissionClientPeer
15+
) where
16+
17+
import DMQ.Protocol.LocalMsgSubmission.Type
18+
import Network.TypedProtocol.Peer.Client
19+
import Ouroboros.Network.Protocol.LocalTxSubmission.Client
20+
21+
-- | Type aliases for the high level client API
22+
--
23+
type LocalMsgSubmissionClient = LocalTxSubmissionClient
24+
type LocalMsgClientStIdle = LocalTxClientStIdle
25+
26+
27+
-- | A non-pipelined 'Peer' representing the 'LocalMsgSubmissionClient'.
28+
--
29+
-- Translates a high level client description into the underlying typed
30+
-- protocol representation.
31+
--
32+
localMsgSubmissionClientPeer
33+
:: forall msg reject m a. Monad m
34+
=> LocalMsgSubmissionClient msg reject m a
35+
-> Client (LocalMsgSubmission msg reject) NonPipelined StIdle m a
36+
localMsgSubmissionClientPeer = localTxSubmissionClientPeer
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{-# LANGUAGE RankNTypes #-}
2+
3+
-- | The codec for the local message submission miniprotocol
4+
--
5+
module DMQ.Protocol.LocalMsgSubmission.Codec where
6+
7+
import Codec.CBOR.Decoding qualified as CBOR
8+
import Codec.CBOR.Encoding qualified as CBOR
9+
import Codec.CBOR.Read qualified as CBOR
10+
import Control.Monad.Class.MonadST
11+
import Data.ByteString.Lazy (ByteString)
12+
13+
import DMQ.Protocol.LocalMsgSubmission.Type
14+
import Network.TypedProtocol.Codec.CBOR
15+
import Ouroboros.Network.Protocol.LocalTxSubmission.Codec
16+
17+
codecLocalMsgSubmission
18+
:: forall msg reject m.
19+
MonadST m
20+
=> (msg -> CBOR.Encoding)
21+
-> (forall s. CBOR.Decoder s msg)
22+
-> (reject -> CBOR.Encoding)
23+
-> (forall s. CBOR.Decoder s reject)
24+
-> Codec (LocalMsgSubmission msg reject) CBOR.DeserialiseFailure m ByteString
25+
codecLocalMsgSubmission =
26+
codecLocalTxSubmission
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{-# LANGUAGE DataKinds #-}
2+
3+
-- | A higher level API to implement server for local message submission
4+
-- miniprotocol. This aliases the server from the 'LocalTxSubmission' protocol.
5+
--
6+
-- For execution, 'localMsgSubmissionServerPeer' reinterprets this high level
7+
-- description into the underlying typed protocol representation.
8+
--
9+
module DMQ.Protocol.LocalMsgSubmission.Server
10+
( -- * Server API types (re-exports)
11+
LocalMsgSubmissionServer
12+
-- * Translates the server into a typed protocol
13+
, localMsgSubmissionServerPeer
14+
) where
15+
16+
import DMQ.Protocol.LocalMsgSubmission.Type
17+
import Network.TypedProtocol.Peer.Server
18+
import Ouroboros.Network.Protocol.LocalTxSubmission.Server
19+
20+
-- | Type aliases for the high level client API
21+
--
22+
type LocalMsgSubmissionServer = LocalTxSubmissionServer
23+
24+
25+
-- | A non-pipelined 'Peer' representing the 'LocalMsgSubmissionServer'.
26+
--
27+
-- Translates a high level server description into the underying typed
28+
-- protocol representation.
29+
--
30+
localMsgSubmissionServerPeer
31+
:: forall msg reject m a.
32+
Monad m
33+
=> m (LocalMsgSubmissionServer msg reject m a)
34+
-> Server (LocalMsgSubmission msg reject) NonPipelined StIdle m a
35+
localMsgSubmissionServerPeer = localTxSubmissionServerPeer
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{-# LANGUAGE DataKinds #-}
2+
{-# LANGUAGE FlexibleInstances #-}
3+
{-# LANGUAGE PolyKinds #-}
4+
{-# LANGUAGE TypeFamilies #-}
5+
6+
-- | This module provides the type of LocalMsgProtocol via LocalTxSubmission
7+
--
8+
module DMQ.Protocol.LocalMsgSubmission.Type
9+
( module DMQ.Protocol.LocalMsgSubmission.Type
10+
-- * re-exports
11+
, module Core
12+
, module Ouroboros
13+
, SubmitResult (..)
14+
) where
15+
16+
import Ouroboros.Network.Protocol.LocalTxSubmission.Type as Ouroboros
17+
import Network.TypedProtocol.Core as Core
18+
19+
-- | The LocalMsgSubmission protocol is an alias for the LocalTxSubmission
20+
--
21+
type LocalMsgSubmission = Ouroboros.LocalTxSubmission

0 commit comments

Comments
 (0)