Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ouroboros-network-protocols/bench-cddl/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,10 @@ localStateQueryMessages =
, AnyMessageWithResult
(Stateful.AnyMessage
StateAcquired
(MsgQuery (Query largeCBORBS)))
(MsgQuery (Query . BlockQuery $ largeCBORBS)))
, AnyMessageWithResult
(Stateful.AnyMessage
(StateQuerying (Query largeCBORBS))
(StateQuerying (Query . BlockQuery $ largeCBORBS))
(MsgResult (Result (Any CBOR.TNull))))
, AnyMessageWithResult
(Stateful.AnyMessage
Expand Down
19 changes: 15 additions & 4 deletions ouroboros-network-protocols/cddl/specs/local-state-query.cddl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
; LocalStateQuery mini-protocol.
;

localStateQueryMessage
localStateQueryMessage = localStateQueryMessageImpl<query>

localStateQueryMessageImpl<q>
= msgAcquire
/ msgAcquired
/ msgFailure
/ msgQuery
/ msgQuery<q>
/ msgResult
/ msgRelease
/ msgReAcquire
Expand All @@ -18,15 +20,24 @@ acquireFailurePointNotOnChain = 1
failure = acquireFailurePointTooOld
/ acquireFailurePointNotOnChain

query = any
blockQuery = [0, point]
getSystemStart = [1]
getChainBlockNo = [2]
getChainPoint = [3]

query = blockQuery
/ getSystemStart
/ getChainBlockNo
/ getChainPoint

result = any

msgAcquire = [0, point]
/ [8]
/ [10]
msgAcquired = [1]
msgFailure = [2, failure]
msgQuery = [3, query]
msgQuery<q> = [3, q]
msgResult = [4, result]
msgRelease = [5]
msgReAcquire = [6, point]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
Expand All @@ -20,14 +22,29 @@ import Ouroboros.Network.Protocol.BlockFetch.Codec.CDDL (Block, BlockPoint)
import Ouroboros.Network.Protocol.LocalStateQuery.Codec
import Ouroboros.Network.Protocol.LocalStateQuery.Type
import Test.Data.CDDL (Any)
import Test.QuickCheck (Arbitrary (..))
import Test.QuickCheck (Arbitrary (..), oneof)

newtype Result = Result Any
deriving (Eq, Show, Arbitrary, Serialise, Generic, NFData)
deriving stock (Eq, Show, Generic)
deriving newtype (Arbitrary, Serialise, NFData)

data QueryPayload =
BlockQuery Any
| GetSystemStart
| GetChainBlockNo
| GetChainPoint
deriving stock (Eq, Show, Generic)
deriving anyclass (Serialise, NFData)

instance Arbitrary QueryPayload where
arbitrary = oneof [ BlockQuery <$> arbitrary
, pure GetSystemStart
, pure GetChainBlockNo
, pure GetChainPoint
]

-- TODO: add payload to the query
data Query result where
Query :: Any -> Query Result
Query :: QueryPayload -> Query Result

instance NFData (Query result) where
rnf (Query a) = rnf a
Expand Down
Loading