Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Ouroboros.Consensus.Ledger.Query
Synopsis
- data family BlockQuery blk ∷ Type → Type
- class (ShowQuery (BlockQuery blk), SameDepIndex (BlockQuery blk)) ⇒ BlockSupportsLedgerQuery blk where
- answerBlockQuery ∷ ExtLedgerCfg blk → BlockQuery blk result → ExtLedgerState blk → result
- blockQueryIsSupportedOnVersion ∷ BlockQuery blk result → BlockNodeToClientVersion blk → Bool
- class ConfigSupportsNode blk where
- getSystemStart ∷ BlockConfig blk → SystemStart
- getNetworkMagic ∷ BlockConfig blk → NetworkMagic
- data Query blk result where
- BlockQuery ∷ BlockQuery blk result → Query blk result
- GetSystemStart ∷ Query blk SystemStart
- GetChainBlockNo ∷ Query blk (WithOrigin BlockNo)
- GetChainPoint ∷ Query blk (Point blk)
- GetLedgerConfig ∷ Query blk (LedgerConfig blk)
- data QueryVersion
- class (∀ result. Show (query result)) ⇒ ShowQuery (query ∷ Type → Type) where
- showResult ∷ query result → result → String
- answerQuery ∷ (BlockSupportsLedgerQuery blk, ConfigSupportsNode blk, HasAnnTip blk) ⇒ ExtLedgerCfg blk → Query blk result → ExtLedgerState blk → result
- nodeToClientVersionToQueryVersion ∷ NodeToClientVersion → QueryVersion
- queryDecodeNodeToClient ∷ ∀ blk. SerialiseNodeToClient blk (SomeSecond BlockQuery blk) ⇒ CodecConfig blk → QueryVersion → BlockNodeToClientVersion blk → ∀ s. Decoder s (SomeSecond Query blk)
- queryEncodeNodeToClient ∷ ∀ blk. (Typeable blk, BlockSupportsLedgerQuery blk, Show (BlockNodeToClientVersion blk)) ⇒ Show (SomeSecond BlockQuery blk) ⇒ SerialiseNodeToClient blk (SomeSecond BlockQuery blk) ⇒ CodecConfig blk → QueryVersion → BlockNodeToClientVersion blk → SomeSecond Query blk → Encoding
- queryIsSupportedOnNodeToClientVersion ∷ ∀ blk result. (SupportedNetworkProtocolVersion blk, BlockSupportsLedgerQuery blk) ⇒ Query blk result → NodeToClientVersion → Bool
- querySupportedVersions ∷ ∀ blk result. (SupportedNetworkProtocolVersion blk, BlockSupportsLedgerQuery blk) ⇒ Query blk result → [NodeToClientVersion]
Documentation
data family BlockQuery blk ∷ Type → Type Source #
Different queries supported by the ledger, indexed by the result type.
Instances
class (ShowQuery (BlockQuery blk), SameDepIndex (BlockQuery blk)) ⇒ BlockSupportsLedgerQuery blk where Source #
Query the ledger extended state.
Used by the LocalStateQuery protocol to allow clients to query the extended ledger state.
Methods
answerBlockQuery ∷ ExtLedgerCfg blk → BlockQuery blk result → ExtLedgerState blk → result Source #
Answer the given query about the extended ledger state.
blockQueryIsSupportedOnVersion ∷ BlockQuery blk result → BlockNodeToClientVersion blk → Bool Source #
Is the given query supported in this NTC version?
Encoders for queries should call this function before attempting to send a query. The node will still try to answer block queries it knows about even if they are not guaranteed to be supported on the negotiated version, but clients can benefit of knowing beforehand whether the query is expected to not work, even if it decides to send it anyways.
More reasoning on how queries are versioned in Consensus can be seen in https://ouroboros-consensus.cardano.intersectmbo.org/docs/for-developers/QueryVersioning/. In particular this function implements the check described in https://ouroboros-consensus.cardano.intersectmbo.org/docs/for-developers/QueryVersioning/#checks.
Instances
(All SingleEraBlock xs, All BlockSupportsLedgerQuery xs) ⇒ BlockSupportsLedgerQuery (HardForkBlock xs) Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger.Query Methods answerBlockQuery ∷ ExtLedgerCfg (HardForkBlock xs) → BlockQuery (HardForkBlock xs) result → ExtLedgerState (HardForkBlock xs) → result Source # blockQueryIsSupportedOnVersion ∷ BlockQuery (HardForkBlock xs) result → BlockNodeToClientVersion (HardForkBlock xs) → Bool Source # | |
Bridge m a ⇒ BlockSupportsLedgerQuery (DualBlock m a) Source # | Not used in the tests: no constructors |
Defined in Ouroboros.Consensus.Ledger.Dual Methods answerBlockQuery ∷ ExtLedgerCfg (DualBlock m a) → BlockQuery (DualBlock m a) result → ExtLedgerState (DualBlock m a) → result Source # blockQueryIsSupportedOnVersion ∷ BlockQuery (DualBlock m a) result → BlockNodeToClientVersion (DualBlock m a) → Bool Source # |
class ConfigSupportsNode blk where Source #
The BlockConfig
needs to contain some information in order to support
running a node.
Methods
getSystemStart ∷ BlockConfig blk → SystemStart Source #
getNetworkMagic ∷ BlockConfig blk → NetworkMagic Source #
Instances
CanHardFork xs ⇒ ConfigSupportsNode (HardForkBlock xs) Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Node Methods getSystemStart ∷ BlockConfig (HardForkBlock xs) → SystemStart Source # getNetworkMagic ∷ BlockConfig (HardForkBlock xs) → NetworkMagic Source # | |
ConfigSupportsNode m ⇒ ConfigSupportsNode (DualBlock m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual Methods getSystemStart ∷ BlockConfig (DualBlock m a) → SystemStart Source # getNetworkMagic ∷ BlockConfig (DualBlock m a) → NetworkMagic Source # |
data Query blk result where Source #
Different queries supported by the ledger for all block types, indexed by the result type.
Additions to the set of queries is versioned by QueryVersion
Constructors
BlockQuery ∷ BlockQuery blk result → Query blk result | This constructor is supported by all |
GetSystemStart ∷ Query blk SystemStart | Get the Supported by |
GetChainBlockNo ∷ Query blk (WithOrigin BlockNo) | Get the Supported by |
GetChainPoint ∷ Query blk (Point blk) | Get the Supported by |
GetLedgerConfig ∷ Query blk (LedgerConfig blk) | Get the ledger config. This constructor is supported by |
Instances
data QueryVersion Source #
Version of the `Query blk` type.
Multiple top level queries are now supported. The encoding now has constructor tags for the different top level queries for QueryVersion1 onwards.
Constructors
QueryVersion1 | |
QueryVersion2 | |
QueryVersion3 |
Instances
class (∀ result. Show (query result)) ⇒ ShowQuery (query ∷ Type → Type) where Source #
To implement Show
for:
('Message' ('LocalStateQuery' block query) st st')
we need a way to print the query
GADT and its type index, result
. This
class contain the method we need to provide this Show
instance.
We use a type class for this, as this Show
constraint propagates to a lot
of places.
Methods
showResult ∷ query result → result → String Source #
Instances
answerQuery ∷ (BlockSupportsLedgerQuery blk, ConfigSupportsNode blk, HasAnnTip blk) ⇒ ExtLedgerCfg blk → Query blk result → ExtLedgerState blk → result Source #
Answer the given query about the extended ledger state.
nodeToClientVersionToQueryVersion ∷ NodeToClientVersion → QueryVersion Source #
Get the QueryVersion
supported by this NodeToClientVersion
.
queryDecodeNodeToClient ∷ ∀ blk. SerialiseNodeToClient blk (SomeSecond BlockQuery blk) ⇒ CodecConfig blk → QueryVersion → BlockNodeToClientVersion blk → ∀ s. Decoder s (SomeSecond Query blk) Source #
queryEncodeNodeToClient ∷ ∀ blk. (Typeable blk, BlockSupportsLedgerQuery blk, Show (BlockNodeToClientVersion blk)) ⇒ Show (SomeSecond BlockQuery blk) ⇒ SerialiseNodeToClient blk (SomeSecond BlockQuery blk) ⇒ CodecConfig blk → QueryVersion → BlockNodeToClientVersion blk → SomeSecond Query blk → Encoding Source #
queryIsSupportedOnNodeToClientVersion ∷ ∀ blk result. (SupportedNetworkProtocolVersion blk, BlockSupportsLedgerQuery blk) ⇒ Query blk result → NodeToClientVersion → Bool Source #
querySupportedVersions ∷ ∀ blk result. (SupportedNetworkProtocolVersion blk, BlockSupportsLedgerQuery blk) ⇒ Query blk result → [NodeToClientVersion] Source #