Skip to content

Commit

Permalink
Merge #2633
Browse files Browse the repository at this point in the history
2633: Support for LedgerState and folding over all blocks r=DavidEichmann a=DavidEichmann

The `foldBlocks` function was originally used by @JaredCorduan to implement an audit tool. In my first commit I remove the existing cardano-api `LedgerState` type and corresponding queries. This is to make room for the new `LedgerState` type that I introduce in the second commit.

I eventually plan to add a query for the full ledger state. Once that is merged, I'll be able to reintroduce the queries that I've removed here.  

Co-authored-by: David Eichmann <EichmannD@gmail.com>
  • Loading branch information
iohk-bors[bot] and DavidEichmann authored Apr 27, 2021
2 parents 314c3a5 + e51b3c6 commit fecdb3b
Show file tree
Hide file tree
Showing 12 changed files with 1,000 additions and 43 deletions.
3 changes: 3 additions & 0 deletions cardano-api/cardano-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ library
Cardano.Api.KeysByron
Cardano.Api.KeysPraos
Cardano.Api.KeysShelley
Cardano.Api.LedgerState
Cardano.Api.Modes
Cardano.Api.NetworkId
Cardano.Api.OperationalCertificate
Expand Down Expand Up @@ -112,6 +113,7 @@ library
, formatting
, iproute
, memory
, mtl
, network
, nothunks
, ouroboros-consensus
Expand All @@ -131,6 +133,7 @@ library
, typed-protocols
, unordered-containers >= 0.2.11
, vector
, yaml

test-suite cardano-api-test
import: base, project-config
Expand Down
22 changes: 21 additions & 1 deletion cardano-api/src/Cardano/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ module Cardano.Api (
BlockHeader(..),

-- ** Points on the chain
ChainPoint,
ChainPoint(..),
EpochNo(..),

-- ** Tip of the chain
Expand Down Expand Up @@ -398,6 +398,25 @@ module Cardano.Api (
-- ** Queries
-- ** Submitting transactions

-- ** High level protocol interaction with a Cardano node
-- *** Initialization / Accumulation
Env(..),
envSecurityParam,
LedgerState(..),
initialLedgerState,
applyBlock,

-- *** Traversing the block chain
foldBlocks,

-- *** Errors
FoldBlocksError(..),
GenesisConfigError(..),
InitialLedgerStateError(..),
renderFoldBlocksError,
renderGenesisConfigError,
renderInitialLedgerStateError,

-- ** Low level protocol interaction with a Cardano node
connectToLocalNode,
LocalNodeConnectInfo(..),
Expand Down Expand Up @@ -492,6 +511,7 @@ import Cardano.Api.Key
import Cardano.Api.KeysByron
import Cardano.Api.KeysPraos
import Cardano.Api.KeysShelley
import Cardano.Api.LedgerState
import Cardano.Api.Modes
import Cardano.Api.NetworkId
import Cardano.Api.OperationalCertificate
Expand Down
2 changes: 2 additions & 0 deletions cardano-api/src/Cardano/Api/Block.hs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ data Block era where
pattern Block :: BlockHeader -> [Tx era] -> Block era
pattern Block header txs <- (getBlockHeaderAndTxs -> (header, txs))

{-# COMPLETE Block #-}

getBlockHeaderAndTxs :: Block era -> (BlockHeader, [Tx era])
getBlockHeaderAndTxs block = (getBlockHeader block, getBlockTxs block)

Expand Down
Loading

0 comments on commit fecdb3b

Please sign in to comment.