Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop exporting constructors for BlockHeader and PayloadData #1862

Closed
11 changes: 8 additions & 3 deletions bench/Chainweb/Pact/Backend/Bench.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module Chainweb.Pact.Backend.Bench


import Control.Concurrent
import Control.Lens
import Control.Monad
import Control.Monad.Catch
import qualified Criterion.Main as C
Expand Down Expand Up @@ -46,7 +47,7 @@ import qualified Pact.Types.SQLite as PSQL
-- chainweb imports

import Chainweb.BlockHash
import Chainweb.BlockHeader
import Chainweb.BlockHeader.Internal
import Chainweb.Graph
import Chainweb.Logger
import Chainweb.MerkleLogHash
Expand Down Expand Up @@ -80,9 +81,13 @@ cpRestoreAndSave cp pc blks = snd <$> _cpRestoreAndSave cp (ParentHeader <$> pc)
-- | fabricate a `BlockHeader` for a block given its hash and its parent.
childOf :: Maybe BlockHeader -> BlockHash -> BlockHeader
childOf (Just bh) bhsh =
bh { _blockHash = bhsh, _blockParent = _blockHash bh, _blockHeight = _blockHeight bh + 1 }
bh
& blockHash .~ bhsh
& blockParent .~ (_blockHash bh)
& blockHeight +~ 1
childOf Nothing bhsh =
(genesisBlockHeader testVer testChainId) { _blockHash = bhsh }
genesisBlockHeader testVer testChainId
& blockHash .~ bhsh


bench :: C.Benchmark
Expand Down
2 changes: 1 addition & 1 deletion bench/Chainweb/Pact/Backend/ForkingBench.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ import Pact.Types.Util hiding (unwrap)
-- chainweb imports

import Chainweb.BlockCreationTime
import Chainweb.BlockHeader
import Chainweb.BlockHeader.Internal
import Chainweb.BlockHeaderDB
import Chainweb.BlockHeaderDB.Internal
import Chainweb.BlockHeight (BlockHeight(..))
Expand Down
2 changes: 2 additions & 0 deletions chainweb.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ library
, Chainweb.BlockCreationTime
, Chainweb.BlockHash
, Chainweb.BlockHeader
, Chainweb.BlockHeader.Internal
, Chainweb.BlockHeader.Genesis.RecapDevelopment0Payload
, Chainweb.BlockHeader.Genesis.RecapDevelopment1to9Payload
, Chainweb.BlockHeader.Genesis.RecapDevelopment10to19Payload
Expand Down Expand Up @@ -216,6 +217,7 @@ library
, Chainweb.NodeVersion
, Chainweb.OpenAPIValidation
, Chainweb.Payload
, Chainweb.Payload.Internal
, Chainweb.Payload.PayloadStore
, Chainweb.Payload.PayloadStore.InMemory
, Chainweb.Payload.PayloadStore.RocksDB
Expand Down
4 changes: 2 additions & 2 deletions node/ChainwebNode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ runBlockUpdateMonitor logger db = L.withLoggerLabel ("component", "block-update-

txCount :: BlockHeader -> IO Int
txCount bh = do
bp <- lookupPayloadDataWithHeight payloadDb (Just $ _blockHeight bh) (_blockPayloadHash bh) >>= \case
bp <- lookupPayloadDataWithHeight payloadDb (Just $ view blockHeight bh) (view blockPayloadHash bh) >>= \case
Nothing -> error "block payload not found"
Just x -> return x
return $ length $ _payloadDataTransactions bp
return $ length $ view payloadDataTransactions bp

toUpdate :: Either BlockHeader BlockHeader -> IO BlockUpdate
toUpdate (Right bh) = BlockUpdate
Expand Down
Loading
Loading