{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
module Ouroboros.Consensus.Storage.ChainDB.API (
ChainDB (..)
, getCurrentLedger
, getCurrentTip
, getImmutableLedger
, getPastLedger
, getTipBlockNo
, AddBlockPromise (..)
, AddBlockResult (..)
, addBlock
, addBlockWaitWrittenToDisk
, addBlock_
, ChainSelectionPromise (..)
, triggerChainSelection
, triggerChainSelectionAsync
, WithPoint (..)
, getPoint
, getSerialisedBlockWithPoint
, getSerialisedHeaderWithPoint
, BlockComponent (..)
, fromChain
, toChain
, Iterator (..)
, IteratorResult (..)
, StreamFrom (..)
, StreamTo (..)
, UnknownRange (..)
, emptyIterator
, streamAll
, streamFrom
, traverseIterator
, validBounds
, ChainType (..)
, Follower (..)
, traverseFollower
, ChainDbFailure (..)
, IsEBB (..)
, ChainDbError (..)
, GetLoEFragment
, LoE (..)
) where
import Control.Monad (void)
import Control.ResourceRegistry
import Data.Typeable (Typeable)
import GHC.Generics (Generic)
import Ouroboros.Consensus.Block
import Ouroboros.Consensus.HeaderStateHistory
(HeaderStateHistory (..))
import Ouroboros.Consensus.Ledger.Abstract
import Ouroboros.Consensus.Ledger.Extended
import Ouroboros.Consensus.Ledger.SupportsProtocol
import Ouroboros.Consensus.Storage.ChainDB.API.Types.InvalidBlockPunishment
(InvalidBlockPunishment)
import qualified Ouroboros.Consensus.Storage.ChainDB.API.Types.InvalidBlockPunishment as InvalidBlockPunishment
import Ouroboros.Consensus.Storage.Common
import Ouroboros.Consensus.Storage.LedgerDB (LedgerDB')
import qualified Ouroboros.Consensus.Storage.LedgerDB as LedgerDB
import Ouroboros.Consensus.Storage.Serialisation
import Ouroboros.Consensus.Util ((..:))
import Ouroboros.Consensus.Util.CallStack
import Ouroboros.Consensus.Util.IOLike
import Ouroboros.Consensus.Util.STM (WithFingerprint)
import Ouroboros.Network.AnchoredFragment (AnchoredFragment)
import qualified Ouroboros.Network.AnchoredFragment as AF
import Ouroboros.Network.Block (ChainUpdate, MaxSlotNo,
Serialised (..))
import qualified Ouroboros.Network.Block as Network
import Ouroboros.Network.Mock.Chain (Chain (..))
import qualified Ouroboros.Network.Mock.Chain as Chain
import System.FS.API.Types (FsError)
data ChainDB m blk = ChainDB {
forall (m :: * -> *) blk.
ChainDB m blk
-> InvalidBlockPunishment m -> blk -> m (AddBlockPromise m blk)
addBlockAsync :: InvalidBlockPunishment m -> blk -> m (AddBlockPromise m blk)
, forall (m :: * -> *) blk.
ChainDB m blk -> m (ChainSelectionPromise m)
chainSelAsync :: m (ChainSelectionPromise m)
, forall (m :: * -> *) blk.
ChainDB m blk -> STM m (AnchoredFragment (Header blk))
getCurrentChain :: STM m (AnchoredFragment (Header blk))
, forall (m :: * -> *) blk. ChainDB m blk -> STM m (LedgerDB' blk)
getLedgerDB :: STM m (LedgerDB' blk)
, :: STM m (HeaderStateHistory blk)
, forall (m :: * -> *) blk. ChainDB m blk -> m (Maybe blk)
getTipBlock :: m (Maybe blk)
, :: m (Maybe (Header blk))
, forall (m :: * -> *) blk. ChainDB m blk -> STM m (Point blk)
getTipPoint :: STM m (Point blk)
, forall (m :: * -> *) blk.
ChainDB m blk
-> forall b. BlockComponent blk b -> RealPoint blk -> m (Maybe b)
getBlockComponent :: forall b. BlockComponent blk b
-> RealPoint blk -> m (Maybe b)
, forall (m :: * -> *) blk.
ChainDB m blk -> STM m (Point blk -> Bool)
getIsFetched :: STM m (Point blk -> Bool)
, forall (m :: * -> *) blk.
ChainDB m blk -> STM m (RealPoint blk -> Maybe Bool)
getIsValid :: STM m (RealPoint blk -> Maybe Bool)
, forall (m :: * -> *) blk. ChainDB m blk -> STM m MaxSlotNo
getMaxSlotNo :: STM m MaxSlotNo
, forall (m :: * -> *) blk.
ChainDB m blk
-> forall b.
ResourceRegistry m
-> BlockComponent blk b
-> StreamFrom blk
-> StreamTo blk
-> m (Either (UnknownRange blk) (Iterator m blk b))
stream ::
forall b. ResourceRegistry m
-> BlockComponent blk b
-> StreamFrom blk -> StreamTo blk
-> m (Either (UnknownRange blk) (Iterator m blk b))
, forall (m :: * -> *) blk.
ChainDB m blk
-> forall b.
ResourceRegistry m
-> ChainType -> BlockComponent blk b -> m (Follower m blk b)
newFollower ::
forall b. ResourceRegistry m
-> ChainType
-> BlockComponent blk b
-> m (Follower m blk b)
, forall (m :: * -> *) blk.
ChainDB m blk
-> STM
m
(WithFingerprint
(HeaderHash blk -> Maybe (ExtValidationError blk)))
getIsInvalidBlock :: STM m (WithFingerprint (HeaderHash blk -> Maybe (ExtValidationError blk)))
, forall (m :: * -> *) blk. ChainDB m blk -> m ()
closeDB :: m ()
, forall (m :: * -> *) blk. ChainDB m blk -> STM m Bool
isOpen :: STM m Bool
}
getCurrentTip :: (Monad (STM m), HasHeader (Header blk))
=> ChainDB m blk -> STM m (Network.Tip blk)
getCurrentTip :: forall (m :: * -> *) blk.
(Monad (STM m), HasHeader (Header blk)) =>
ChainDB m blk -> STM m (Tip blk)
getCurrentTip = (AnchoredSeq (WithOrigin SlotNo) (Anchor (Header blk)) (Header blk)
-> Tip blk)
-> STM
m
(AnchoredSeq
(WithOrigin SlotNo) (Anchor (Header blk)) (Header blk))
-> STM m (Tip blk)
forall a b. (a -> b) -> STM m a -> STM m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Anchor (Header blk) -> Tip blk
forall a b. (HeaderHash a ~ HeaderHash b) => Anchor a -> Tip b
AF.anchorToTip (Anchor (Header blk) -> Tip blk)
-> (AnchoredSeq
(WithOrigin SlotNo) (Anchor (Header blk)) (Header blk)
-> Anchor (Header blk))
-> AnchoredSeq
(WithOrigin SlotNo) (Anchor (Header blk)) (Header blk)
-> Tip blk
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AnchoredSeq (WithOrigin SlotNo) (Anchor (Header blk)) (Header blk)
-> Anchor (Header blk)
forall v a b. Anchorable v a b => AnchoredSeq v a b -> a
AF.headAnchor) (STM
m
(AnchoredSeq
(WithOrigin SlotNo) (Anchor (Header blk)) (Header blk))
-> STM m (Tip blk))
-> (ChainDB m blk
-> STM
m
(AnchoredSeq
(WithOrigin SlotNo) (Anchor (Header blk)) (Header blk)))
-> ChainDB m blk
-> STM m (Tip blk)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ChainDB m blk
-> STM
m
(AnchoredSeq
(WithOrigin SlotNo) (Anchor (Header blk)) (Header blk))
forall (m :: * -> *) blk.
ChainDB m blk -> STM m (AnchoredFragment (Header blk))
getCurrentChain
getTipBlockNo :: (Monad (STM m), HasHeader (Header blk))
=> ChainDB m blk -> STM m (WithOrigin BlockNo)
getTipBlockNo :: forall (m :: * -> *) blk.
(Monad (STM m), HasHeader (Header blk)) =>
ChainDB m blk -> STM m (WithOrigin BlockNo)
getTipBlockNo = (Tip blk -> WithOrigin BlockNo)
-> STM m (Tip blk) -> STM m (WithOrigin BlockNo)
forall a b. (a -> b) -> STM m a -> STM m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Tip blk -> WithOrigin BlockNo
forall {k} (b :: k). Tip b -> WithOrigin BlockNo
Network.getTipBlockNo (STM m (Tip blk) -> STM m (WithOrigin BlockNo))
-> (ChainDB m blk -> STM m (Tip blk))
-> ChainDB m blk
-> STM m (WithOrigin BlockNo)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ChainDB m blk -> STM m (Tip blk)
forall (m :: * -> *) blk.
(Monad (STM m), HasHeader (Header blk)) =>
ChainDB m blk -> STM m (Tip blk)
getCurrentTip
getCurrentLedger ::
(Monad (STM m), IsLedger (LedgerState blk))
=> ChainDB m blk -> STM m (ExtLedgerState blk)
getCurrentLedger :: forall (m :: * -> *) blk.
(Monad (STM m), IsLedger (LedgerState blk)) =>
ChainDB m blk -> STM m (ExtLedgerState blk)
getCurrentLedger = (LedgerDB (ExtLedgerState blk) -> ExtLedgerState blk)
-> STM m (LedgerDB (ExtLedgerState blk))
-> STM m (ExtLedgerState blk)
forall a b. (a -> b) -> STM m a -> STM m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap LedgerDB (ExtLedgerState blk) -> ExtLedgerState blk
forall l. GetTip l => LedgerDB l -> l
LedgerDB.ledgerDbCurrent (STM m (LedgerDB (ExtLedgerState blk))
-> STM m (ExtLedgerState blk))
-> (ChainDB m blk -> STM m (LedgerDB (ExtLedgerState blk)))
-> ChainDB m blk
-> STM m (ExtLedgerState blk)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ChainDB m blk -> STM m (LedgerDB (ExtLedgerState blk))
forall (m :: * -> *) blk. ChainDB m blk -> STM m (LedgerDB' blk)
getLedgerDB
getImmutableLedger ::
Monad (STM m)
=> ChainDB m blk -> STM m (ExtLedgerState blk)
getImmutableLedger :: forall (m :: * -> *) blk.
Monad (STM m) =>
ChainDB m blk -> STM m (ExtLedgerState blk)
getImmutableLedger = (LedgerDB (ExtLedgerState blk) -> ExtLedgerState blk)
-> STM m (LedgerDB (ExtLedgerState blk))
-> STM m (ExtLedgerState blk)
forall a b. (a -> b) -> STM m a -> STM m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap LedgerDB (ExtLedgerState blk) -> ExtLedgerState blk
forall l. LedgerDB l -> l
LedgerDB.ledgerDbAnchor (STM m (LedgerDB (ExtLedgerState blk))
-> STM m (ExtLedgerState blk))
-> (ChainDB m blk -> STM m (LedgerDB (ExtLedgerState blk)))
-> ChainDB m blk
-> STM m (ExtLedgerState blk)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ChainDB m blk -> STM m (LedgerDB (ExtLedgerState blk))
forall (m :: * -> *) blk. ChainDB m blk -> STM m (LedgerDB' blk)
getLedgerDB
getPastLedger ::
(Monad (STM m), LedgerSupportsProtocol blk)
=> ChainDB m blk -> Point blk -> STM m (Maybe (ExtLedgerState blk))
getPastLedger :: forall (m :: * -> *) blk.
(Monad (STM m), LedgerSupportsProtocol blk) =>
ChainDB m blk -> Point blk -> STM m (Maybe (ExtLedgerState blk))
getPastLedger ChainDB m blk
db Point blk
pt = Point blk
-> LedgerDB (ExtLedgerState blk) -> Maybe (ExtLedgerState blk)
forall blk l.
(HasHeader blk, IsLedger l, HeaderHash l ~ HeaderHash blk) =>
Point blk -> LedgerDB l -> Maybe l
LedgerDB.ledgerDbPast Point blk
pt (LedgerDB (ExtLedgerState blk) -> Maybe (ExtLedgerState blk))
-> STM m (LedgerDB (ExtLedgerState blk))
-> STM m (Maybe (ExtLedgerState blk))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ChainDB m blk -> STM m (LedgerDB (ExtLedgerState blk))
forall (m :: * -> *) blk. ChainDB m blk -> STM m (LedgerDB' blk)
getLedgerDB ChainDB m blk
db
data AddBlockPromise m blk = AddBlockPromise
{ forall (m :: * -> *) blk. AddBlockPromise m blk -> STM m Bool
blockWrittenToDisk :: STM m Bool
, forall (m :: * -> *) blk.
AddBlockPromise m blk -> STM m (AddBlockResult blk)
blockProcessed :: STM m (AddBlockResult blk)
}
data AddBlockResult blk = SuccesfullyAddedBlock (Point blk)
| FailedToAddBlock String
deriving (AddBlockResult blk -> AddBlockResult blk -> Bool
(AddBlockResult blk -> AddBlockResult blk -> Bool)
-> (AddBlockResult blk -> AddBlockResult blk -> Bool)
-> Eq (AddBlockResult blk)
forall blk.
StandardHash blk =>
AddBlockResult blk -> AddBlockResult blk -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall blk.
StandardHash blk =>
AddBlockResult blk -> AddBlockResult blk -> Bool
== :: AddBlockResult blk -> AddBlockResult blk -> Bool
$c/= :: forall blk.
StandardHash blk =>
AddBlockResult blk -> AddBlockResult blk -> Bool
/= :: AddBlockResult blk -> AddBlockResult blk -> Bool
Eq, Int -> AddBlockResult blk -> ShowS
[AddBlockResult blk] -> ShowS
AddBlockResult blk -> String
(Int -> AddBlockResult blk -> ShowS)
-> (AddBlockResult blk -> String)
-> ([AddBlockResult blk] -> ShowS)
-> Show (AddBlockResult blk)
forall blk. StandardHash blk => Int -> AddBlockResult blk -> ShowS
forall blk. StandardHash blk => [AddBlockResult blk] -> ShowS
forall blk. StandardHash blk => AddBlockResult blk -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall blk. StandardHash blk => Int -> AddBlockResult blk -> ShowS
showsPrec :: Int -> AddBlockResult blk -> ShowS
$cshow :: forall blk. StandardHash blk => AddBlockResult blk -> String
show :: AddBlockResult blk -> String
$cshowList :: forall blk. StandardHash blk => [AddBlockResult blk] -> ShowS
showList :: [AddBlockResult blk] -> ShowS
Show)
addBlockWaitWrittenToDisk :: IOLike m => ChainDB m blk -> InvalidBlockPunishment m -> blk -> m Bool
addBlockWaitWrittenToDisk :: forall (m :: * -> *) blk.
IOLike m =>
ChainDB m blk -> InvalidBlockPunishment m -> blk -> m Bool
addBlockWaitWrittenToDisk ChainDB m blk
chainDB InvalidBlockPunishment m
punish blk
blk = do
AddBlockPromise m blk
promise <- ChainDB m blk
-> InvalidBlockPunishment m -> blk -> m (AddBlockPromise m blk)
forall (m :: * -> *) blk.
ChainDB m blk
-> InvalidBlockPunishment m -> blk -> m (AddBlockPromise m blk)
addBlockAsync ChainDB m blk
chainDB InvalidBlockPunishment m
punish blk
blk
STM m Bool -> m Bool
forall a. HasCallStack => STM m a -> m a
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (STM m Bool -> m Bool) -> STM m Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ AddBlockPromise m blk -> STM m Bool
forall (m :: * -> *) blk. AddBlockPromise m blk -> STM m Bool
blockWrittenToDisk AddBlockPromise m blk
promise
addBlock :: IOLike m => ChainDB m blk -> InvalidBlockPunishment m -> blk -> m (AddBlockResult blk)
addBlock :: forall (m :: * -> *) blk.
IOLike m =>
ChainDB m blk
-> InvalidBlockPunishment m -> blk -> m (AddBlockResult blk)
addBlock ChainDB m blk
chainDB InvalidBlockPunishment m
punish blk
blk = do
AddBlockPromise m blk
promise <- ChainDB m blk
-> InvalidBlockPunishment m -> blk -> m (AddBlockPromise m blk)
forall (m :: * -> *) blk.
ChainDB m blk
-> InvalidBlockPunishment m -> blk -> m (AddBlockPromise m blk)
addBlockAsync ChainDB m blk
chainDB InvalidBlockPunishment m
punish blk
blk
STM m (AddBlockResult blk) -> m (AddBlockResult blk)
forall a. HasCallStack => STM m a -> m a
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (STM m (AddBlockResult blk) -> m (AddBlockResult blk))
-> STM m (AddBlockResult blk) -> m (AddBlockResult blk)
forall a b. (a -> b) -> a -> b
$ AddBlockPromise m blk -> STM m (AddBlockResult blk)
forall (m :: * -> *) blk.
AddBlockPromise m blk -> STM m (AddBlockResult blk)
blockProcessed AddBlockPromise m blk
promise
addBlock_ :: IOLike m => ChainDB m blk -> InvalidBlockPunishment m -> blk -> m ()
addBlock_ :: forall (m :: * -> *) blk.
IOLike m =>
ChainDB m blk -> InvalidBlockPunishment m -> blk -> m ()
addBlock_ = m (AddBlockResult blk) -> m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (m (AddBlockResult blk) -> m ())
-> (ChainDB m blk
-> InvalidBlockPunishment m -> blk -> m (AddBlockResult blk))
-> ChainDB m blk
-> InvalidBlockPunishment m
-> blk
-> m ()
forall y z x0 x1 x2.
(y -> z) -> (x0 -> x1 -> x2 -> y) -> x0 -> x1 -> x2 -> z
..: ChainDB m blk
-> InvalidBlockPunishment m -> blk -> m (AddBlockResult blk)
forall (m :: * -> *) blk.
IOLike m =>
ChainDB m blk
-> InvalidBlockPunishment m -> blk -> m (AddBlockResult blk)
addBlock
triggerChainSelectionAsync :: ChainDB m blk -> m (ChainSelectionPromise m)
triggerChainSelectionAsync :: forall (m :: * -> *) blk.
ChainDB m blk -> m (ChainSelectionPromise m)
triggerChainSelectionAsync = ChainDB m blk -> m (ChainSelectionPromise m)
forall (m :: * -> *) blk.
ChainDB m blk -> m (ChainSelectionPromise m)
chainSelAsync
newtype ChainSelectionPromise m = ChainSelectionPromise {
forall (m :: * -> *). ChainSelectionPromise m -> m ()
waitChainSelectionPromise :: m ()
}
triggerChainSelection :: IOLike m => ChainDB m blk -> m ()
triggerChainSelection :: forall (m :: * -> *) blk. IOLike m => ChainDB m blk -> m ()
triggerChainSelection ChainDB m blk
chainDB =
ChainSelectionPromise m -> m ()
forall (m :: * -> *). ChainSelectionPromise m -> m ()
waitChainSelectionPromise (ChainSelectionPromise m -> m ())
-> m (ChainSelectionPromise m) -> m ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< ChainDB m blk -> m (ChainSelectionPromise m)
forall (m :: * -> *) blk.
ChainDB m blk -> m (ChainSelectionPromise m)
chainSelAsync ChainDB m blk
chainDB
data WithPoint blk b = WithPoint
{ forall blk b. WithPoint blk b -> b
withoutPoint :: !b
, forall blk b. WithPoint blk b -> Point blk
point :: !(Point blk)
}
type instance (WithPoint blk b) = HeaderHash blk
instance StandardHash blk => StandardHash (WithPoint blk b)
getPoint :: BlockComponent blk (Point blk)
getPoint :: forall blk. BlockComponent blk (Point blk)
getPoint = SlotNo -> HeaderHash blk -> Point blk
forall {k} (block :: k). SlotNo -> HeaderHash block -> Point block
BlockPoint (SlotNo -> HeaderHash blk -> Point blk)
-> BlockComponent blk SlotNo
-> BlockComponent blk (HeaderHash blk -> Point blk)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> BlockComponent blk SlotNo
forall blk. BlockComponent blk SlotNo
GetSlot BlockComponent blk (HeaderHash blk -> Point blk)
-> BlockComponent blk (HeaderHash blk)
-> BlockComponent blk (Point blk)
forall a b.
BlockComponent blk (a -> b)
-> BlockComponent blk a -> BlockComponent blk b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> BlockComponent blk (HeaderHash blk)
forall blk. BlockComponent blk (HeaderHash blk)
GetHash
getSerialisedBlockWithPoint ::
BlockComponent blk (WithPoint blk (Serialised blk))
getSerialisedBlockWithPoint :: forall blk. BlockComponent blk (WithPoint blk (Serialised blk))
getSerialisedBlockWithPoint =
Serialised blk -> Point blk -> WithPoint blk (Serialised blk)
forall blk b. b -> Point blk -> WithPoint blk b
WithPoint (Serialised blk -> Point blk -> WithPoint blk (Serialised blk))
-> BlockComponent blk (Serialised blk)
-> BlockComponent blk (Point blk -> WithPoint blk (Serialised blk))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ByteString -> Serialised blk
forall {k} (a :: k). ByteString -> Serialised a
Serialised (ByteString -> Serialised blk)
-> BlockComponent blk ByteString
-> BlockComponent blk (Serialised blk)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> BlockComponent blk ByteString
forall blk. BlockComponent blk ByteString
GetRawBlock) BlockComponent blk (Point blk -> WithPoint blk (Serialised blk))
-> BlockComponent blk (Point blk)
-> BlockComponent blk (WithPoint blk (Serialised blk))
forall a b.
BlockComponent blk (a -> b)
-> BlockComponent blk a -> BlockComponent blk b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> BlockComponent blk (Point blk)
forall blk. BlockComponent blk (Point blk)
getPoint
getSerialisedHeader :: BlockComponent blk (SerialisedHeader blk)
=
((SomeSecond (NestedCtxt Header) blk, ByteString)
-> SerialisedHeader blk)
-> SomeSecond (NestedCtxt Header) blk
-> ByteString
-> SerialisedHeader blk
forall a b c. ((a, b) -> c) -> a -> b -> c
curry (SomeSecond (NestedCtxt Header) blk, ByteString)
-> SerialisedHeader blk
forall blk.
(SomeSecond (NestedCtxt Header) blk, ByteString)
-> SerialisedHeader blk
serialisedHeaderFromPair
(SomeSecond (NestedCtxt Header) blk
-> ByteString -> SerialisedHeader blk)
-> BlockComponent blk (SomeSecond (NestedCtxt Header) blk)
-> BlockComponent blk (ByteString -> SerialisedHeader blk)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> BlockComponent blk (SomeSecond (NestedCtxt Header) blk)
forall blk. BlockComponent blk (SomeSecond (NestedCtxt Header) blk)
GetNestedCtxt
BlockComponent blk (ByteString -> SerialisedHeader blk)
-> BlockComponent blk ByteString
-> BlockComponent blk (SerialisedHeader blk)
forall a b.
BlockComponent blk (a -> b)
-> BlockComponent blk a -> BlockComponent blk b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> BlockComponent blk ByteString
forall blk. BlockComponent blk ByteString
GetRawHeader
getSerialisedHeaderWithPoint ::
BlockComponent blk (WithPoint blk (SerialisedHeader blk))
=
SerialisedHeader blk
-> Point blk -> WithPoint blk (SerialisedHeader blk)
forall blk b. b -> Point blk -> WithPoint blk b
WithPoint (SerialisedHeader blk
-> Point blk -> WithPoint blk (SerialisedHeader blk))
-> BlockComponent blk (SerialisedHeader blk)
-> BlockComponent
blk (Point blk -> WithPoint blk (SerialisedHeader blk))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> BlockComponent blk (SerialisedHeader blk)
forall blk. BlockComponent blk (SerialisedHeader blk)
getSerialisedHeader BlockComponent
blk (Point blk -> WithPoint blk (SerialisedHeader blk))
-> BlockComponent blk (Point blk)
-> BlockComponent blk (WithPoint blk (SerialisedHeader blk))
forall a b.
BlockComponent blk (a -> b)
-> BlockComponent blk a -> BlockComponent blk b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> BlockComponent blk (Point blk)
forall blk. BlockComponent blk (Point blk)
getPoint
toChain ::
forall m blk. (HasCallStack, IOLike m, HasHeader blk)
=> ChainDB m blk -> m (Chain blk)
toChain :: forall (m :: * -> *) blk.
(HasCallStack, IOLike m, HasHeader blk) =>
ChainDB m blk -> m (Chain blk)
toChain ChainDB m blk
chainDB = (ResourceRegistry m -> m (Chain blk)) -> m (Chain blk)
forall (m :: * -> *) a.
(MonadSTM m, MonadMask m, MonadThread m, HasCallStack) =>
(ResourceRegistry m -> m a) -> m a
withRegistry ((ResourceRegistry m -> m (Chain blk)) -> m (Chain blk))
-> (ResourceRegistry m -> m (Chain blk)) -> m (Chain blk)
forall a b. (a -> b) -> a -> b
$ \ResourceRegistry m
registry ->
ChainDB m blk
-> ResourceRegistry m
-> BlockComponent blk blk
-> m (Iterator m blk blk)
forall (m :: * -> *) blk b.
(MonadSTM m, HasHeader blk, HasCallStack) =>
ChainDB m blk
-> ResourceRegistry m
-> BlockComponent blk b
-> m (Iterator m blk b)
streamAll ChainDB m blk
chainDB ResourceRegistry m
registry BlockComponent blk blk
forall blk. BlockComponent blk blk
GetBlock m (Iterator m blk blk)
-> (Iterator m blk blk -> m (Chain blk)) -> m (Chain blk)
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Chain blk -> Iterator m blk blk -> m (Chain blk)
go Chain blk
forall block. Chain block
Genesis
where
go :: Chain blk -> Iterator m blk blk -> m (Chain blk)
go :: Chain blk -> Iterator m blk blk -> m (Chain blk)
go Chain blk
chain Iterator m blk blk
it = do
IteratorResult blk blk
next <- Iterator m blk blk -> m (IteratorResult blk blk)
forall (m :: * -> *) blk b.
Iterator m blk b -> m (IteratorResult blk b)
iteratorNext Iterator m blk blk
it
case IteratorResult blk blk
next of
IteratorResult blk
blk -> Chain blk -> Iterator m blk blk -> m (Chain blk)
go (blk -> Chain blk -> Chain blk
forall block.
HasHeader block =>
block -> Chain block -> Chain block
Chain.addBlock blk
blk Chain blk
chain) Iterator m blk blk
it
IteratorResult blk blk
IteratorExhausted -> Chain blk -> m (Chain blk)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Chain blk
chain
IteratorBlockGCed RealPoint blk
_ ->
String -> m (Chain blk)
forall a. HasCallStack => String -> a
error String
"block on the current chain was garbage-collected"
fromChain ::
forall m blk. IOLike m
=> m (ChainDB m blk)
-> Chain blk
-> m (ChainDB m blk)
fromChain :: forall (m :: * -> *) blk.
IOLike m =>
m (ChainDB m blk) -> Chain blk -> m (ChainDB m blk)
fromChain m (ChainDB m blk)
openDB Chain blk
chain = do
ChainDB m blk
chainDB <- m (ChainDB m blk)
openDB
(blk -> m ()) -> [blk] -> m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (ChainDB m blk -> InvalidBlockPunishment m -> blk -> m ()
forall (m :: * -> *) blk.
IOLike m =>
ChainDB m blk -> InvalidBlockPunishment m -> blk -> m ()
addBlock_ ChainDB m blk
chainDB InvalidBlockPunishment m
forall (m :: * -> *). Applicative m => InvalidBlockPunishment m
InvalidBlockPunishment.noPunishment) ([blk] -> m ()) -> [blk] -> m ()
forall a b. (a -> b) -> a -> b
$ Chain blk -> [blk]
forall block. Chain block -> [block]
Chain.toOldestFirst Chain blk
chain
ChainDB m blk -> m (ChainDB m blk)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return ChainDB m blk
chainDB
data Iterator m blk b = Iterator {
forall (m :: * -> *) blk b.
Iterator m blk b -> m (IteratorResult blk b)
iteratorNext :: m (IteratorResult blk b)
, forall (m :: * -> *) blk b. Iterator m blk b -> m ()
iteratorClose :: m ()
}
deriving ((forall a b. (a -> b) -> Iterator m blk a -> Iterator m blk b)
-> (forall a b. a -> Iterator m blk b -> Iterator m blk a)
-> Functor (Iterator m blk)
forall a b. a -> Iterator m blk b -> Iterator m blk a
forall a b. (a -> b) -> Iterator m blk a -> Iterator m blk b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
forall (m :: * -> *) blk a b.
Functor m =>
a -> Iterator m blk b -> Iterator m blk a
forall (m :: * -> *) blk a b.
Functor m =>
(a -> b) -> Iterator m blk a -> Iterator m blk b
$cfmap :: forall (m :: * -> *) blk a b.
Functor m =>
(a -> b) -> Iterator m blk a -> Iterator m blk b
fmap :: forall a b. (a -> b) -> Iterator m blk a -> Iterator m blk b
$c<$ :: forall (m :: * -> *) blk a b.
Functor m =>
a -> Iterator m blk b -> Iterator m blk a
<$ :: forall a b. a -> Iterator m blk b -> Iterator m blk a
Functor, (forall m. Monoid m => Iterator m blk m -> m)
-> (forall m a. Monoid m => (a -> m) -> Iterator m blk a -> m)
-> (forall m a. Monoid m => (a -> m) -> Iterator m blk a -> m)
-> (forall a b. (a -> b -> b) -> b -> Iterator m blk a -> b)
-> (forall a b. (a -> b -> b) -> b -> Iterator m blk a -> b)
-> (forall b a. (b -> a -> b) -> b -> Iterator m blk a -> b)
-> (forall b a. (b -> a -> b) -> b -> Iterator m blk a -> b)
-> (forall a. (a -> a -> a) -> Iterator m blk a -> a)
-> (forall a. (a -> a -> a) -> Iterator m blk a -> a)
-> (forall a. Iterator m blk a -> [a])
-> (forall a. Iterator m blk a -> Bool)
-> (forall a. Iterator m blk a -> Int)
-> (forall a. Eq a => a -> Iterator m blk a -> Bool)
-> (forall a. Ord a => Iterator m blk a -> a)
-> (forall a. Ord a => Iterator m blk a -> a)
-> (forall a. Num a => Iterator m blk a -> a)
-> (forall a. Num a => Iterator m blk a -> a)
-> Foldable (Iterator m blk)
forall a. Eq a => a -> Iterator m blk a -> Bool
forall a. Num a => Iterator m blk a -> a
forall a. Ord a => Iterator m blk a -> a
forall m. Monoid m => Iterator m blk m -> m
forall a. Iterator m blk a -> Bool
forall a. Iterator m blk a -> Int
forall a. Iterator m blk a -> [a]
forall a. (a -> a -> a) -> Iterator m blk a -> a
forall m a. Monoid m => (a -> m) -> Iterator m blk a -> m
forall b a. (b -> a -> b) -> b -> Iterator m blk a -> b
forall a b. (a -> b -> b) -> b -> Iterator m blk a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
forall (m :: * -> *) blk a.
(Foldable m, Eq a) =>
a -> Iterator m blk a -> Bool
forall (m :: * -> *) blk a.
(Foldable m, Num a) =>
Iterator m blk a -> a
forall (m :: * -> *) blk a.
(Foldable m, Ord a) =>
Iterator m blk a -> a
forall (m :: * -> *) blk m.
(Foldable m, Monoid m) =>
Iterator m blk m -> m
forall (m :: * -> *) blk a. Foldable m => Iterator m blk a -> Bool
forall (m :: * -> *) blk a. Foldable m => Iterator m blk a -> Int
forall (m :: * -> *) blk a. Foldable m => Iterator m blk a -> [a]
forall (m :: * -> *) blk a.
Foldable m =>
(a -> a -> a) -> Iterator m blk a -> a
forall (m :: * -> *) blk m a.
(Foldable m, Monoid m) =>
(a -> m) -> Iterator m blk a -> m
forall (m :: * -> *) blk b a.
Foldable m =>
(b -> a -> b) -> b -> Iterator m blk a -> b
forall (m :: * -> *) blk a b.
Foldable m =>
(a -> b -> b) -> b -> Iterator m blk a -> b
$cfold :: forall (m :: * -> *) blk m.
(Foldable m, Monoid m) =>
Iterator m blk m -> m
fold :: forall m. Monoid m => Iterator m blk m -> m
$cfoldMap :: forall (m :: * -> *) blk m a.
(Foldable m, Monoid m) =>
(a -> m) -> Iterator m blk a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> Iterator m blk a -> m
$cfoldMap' :: forall (m :: * -> *) blk m a.
(Foldable m, Monoid m) =>
(a -> m) -> Iterator m blk a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> Iterator m blk a -> m
$cfoldr :: forall (m :: * -> *) blk a b.
Foldable m =>
(a -> b -> b) -> b -> Iterator m blk a -> b
foldr :: forall a b. (a -> b -> b) -> b -> Iterator m blk a -> b
$cfoldr' :: forall (m :: * -> *) blk a b.
Foldable m =>
(a -> b -> b) -> b -> Iterator m blk a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> Iterator m blk a -> b
$cfoldl :: forall (m :: * -> *) blk b a.
Foldable m =>
(b -> a -> b) -> b -> Iterator m blk a -> b
foldl :: forall b a. (b -> a -> b) -> b -> Iterator m blk a -> b
$cfoldl' :: forall (m :: * -> *) blk b a.
Foldable m =>
(b -> a -> b) -> b -> Iterator m blk a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> Iterator m blk a -> b
$cfoldr1 :: forall (m :: * -> *) blk a.
Foldable m =>
(a -> a -> a) -> Iterator m blk a -> a
foldr1 :: forall a. (a -> a -> a) -> Iterator m blk a -> a
$cfoldl1 :: forall (m :: * -> *) blk a.
Foldable m =>
(a -> a -> a) -> Iterator m blk a -> a
foldl1 :: forall a. (a -> a -> a) -> Iterator m blk a -> a
$ctoList :: forall (m :: * -> *) blk a. Foldable m => Iterator m blk a -> [a]
toList :: forall a. Iterator m blk a -> [a]
$cnull :: forall (m :: * -> *) blk a. Foldable m => Iterator m blk a -> Bool
null :: forall a. Iterator m blk a -> Bool
$clength :: forall (m :: * -> *) blk a. Foldable m => Iterator m blk a -> Int
length :: forall a. Iterator m blk a -> Int
$celem :: forall (m :: * -> *) blk a.
(Foldable m, Eq a) =>
a -> Iterator m blk a -> Bool
elem :: forall a. Eq a => a -> Iterator m blk a -> Bool
$cmaximum :: forall (m :: * -> *) blk a.
(Foldable m, Ord a) =>
Iterator m blk a -> a
maximum :: forall a. Ord a => Iterator m blk a -> a
$cminimum :: forall (m :: * -> *) blk a.
(Foldable m, Ord a) =>
Iterator m blk a -> a
minimum :: forall a. Ord a => Iterator m blk a -> a
$csum :: forall (m :: * -> *) blk a.
(Foldable m, Num a) =>
Iterator m blk a -> a
sum :: forall a. Num a => Iterator m blk a -> a
$cproduct :: forall (m :: * -> *) blk a.
(Foldable m, Num a) =>
Iterator m blk a -> a
product :: forall a. Num a => Iterator m blk a -> a
Foldable, Functor (Iterator m blk)
Foldable (Iterator m blk)
(Functor (Iterator m blk), Foldable (Iterator m blk)) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Iterator m blk a -> f (Iterator m blk b))
-> (forall (f :: * -> *) a.
Applicative f =>
Iterator m blk (f a) -> f (Iterator m blk a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Iterator m blk a -> m (Iterator m blk b))
-> (forall (m :: * -> *) a.
Monad m =>
Iterator m blk (m a) -> m (Iterator m blk a))
-> Traversable (Iterator m blk)
forall (t :: * -> *).
(Functor t, Foldable t) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
Iterator m blk (m a) -> m (Iterator m blk a)
forall (f :: * -> *) a.
Applicative f =>
Iterator m blk (f a) -> f (Iterator m blk a)
forall (m :: * -> *) blk. Traversable m => Functor (Iterator m blk)
forall (m :: * -> *) blk.
Traversable m =>
Foldable (Iterator m blk)
forall (m :: * -> *) blk (m :: * -> *) a.
(Traversable m, Monad m) =>
Iterator m blk (m a) -> m (Iterator m blk a)
forall (m :: * -> *) blk (f :: * -> *) a.
(Traversable m, Applicative f) =>
Iterator m blk (f a) -> f (Iterator m blk a)
forall (m :: * -> *) blk (m :: * -> *) a b.
(Traversable m, Monad m) =>
(a -> m b) -> Iterator m blk a -> m (Iterator m blk b)
forall (m :: * -> *) blk (f :: * -> *) a b.
(Traversable m, Applicative f) =>
(a -> f b) -> Iterator m blk a -> f (Iterator m blk b)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Iterator m blk a -> m (Iterator m blk b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Iterator m blk a -> f (Iterator m blk b)
$ctraverse :: forall (m :: * -> *) blk (f :: * -> *) a b.
(Traversable m, Applicative f) =>
(a -> f b) -> Iterator m blk a -> f (Iterator m blk b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Iterator m blk a -> f (Iterator m blk b)
$csequenceA :: forall (m :: * -> *) blk (f :: * -> *) a.
(Traversable m, Applicative f) =>
Iterator m blk (f a) -> f (Iterator m blk a)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
Iterator m blk (f a) -> f (Iterator m blk a)
$cmapM :: forall (m :: * -> *) blk (m :: * -> *) a b.
(Traversable m, Monad m) =>
(a -> m b) -> Iterator m blk a -> m (Iterator m blk b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Iterator m blk a -> m (Iterator m blk b)
$csequence :: forall (m :: * -> *) blk (m :: * -> *) a.
(Traversable m, Monad m) =>
Iterator m blk (m a) -> m (Iterator m blk a)
sequence :: forall (m :: * -> *) a.
Monad m =>
Iterator m blk (m a) -> m (Iterator m blk a)
Traversable)
emptyIterator :: Monad m => Iterator m blk b
emptyIterator :: forall (m :: * -> *) blk b. Monad m => Iterator m blk b
emptyIterator = Iterator {
iteratorNext :: m (IteratorResult blk b)
iteratorNext = IteratorResult blk b -> m (IteratorResult blk b)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return IteratorResult blk b
forall blk b. IteratorResult blk b
IteratorExhausted
, iteratorClose :: m ()
iteratorClose = () -> m ()
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
}
traverseIterator ::
Monad m
=> (b -> m b')
-> Iterator m blk b
-> Iterator m blk b'
traverseIterator :: forall (m :: * -> *) b b' blk.
Monad m =>
(b -> m b') -> Iterator m blk b -> Iterator m blk b'
traverseIterator b -> m b'
f Iterator m blk b
it = Iterator m blk b
it {
iteratorNext = iteratorNext it >>= traverse f
}
data IteratorResult blk b =
IteratorExhausted
| IteratorResult b
| IteratorBlockGCed (RealPoint blk)
deriving ((forall a b.
(a -> b) -> IteratorResult blk a -> IteratorResult blk b)
-> (forall a b. a -> IteratorResult blk b -> IteratorResult blk a)
-> Functor (IteratorResult blk)
forall a b. a -> IteratorResult blk b -> IteratorResult blk a
forall a b.
(a -> b) -> IteratorResult blk a -> IteratorResult blk b
forall blk a b. a -> IteratorResult blk b -> IteratorResult blk a
forall blk a b.
(a -> b) -> IteratorResult blk a -> IteratorResult blk b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall blk a b.
(a -> b) -> IteratorResult blk a -> IteratorResult blk b
fmap :: forall a b.
(a -> b) -> IteratorResult blk a -> IteratorResult blk b
$c<$ :: forall blk a b. a -> IteratorResult blk b -> IteratorResult blk a
<$ :: forall a b. a -> IteratorResult blk b -> IteratorResult blk a
Functor, (forall m. Monoid m => IteratorResult blk m -> m)
-> (forall m a. Monoid m => (a -> m) -> IteratorResult blk a -> m)
-> (forall m a. Monoid m => (a -> m) -> IteratorResult blk a -> m)
-> (forall a b. (a -> b -> b) -> b -> IteratorResult blk a -> b)
-> (forall a b. (a -> b -> b) -> b -> IteratorResult blk a -> b)
-> (forall b a. (b -> a -> b) -> b -> IteratorResult blk a -> b)
-> (forall b a. (b -> a -> b) -> b -> IteratorResult blk a -> b)
-> (forall a. (a -> a -> a) -> IteratorResult blk a -> a)
-> (forall a. (a -> a -> a) -> IteratorResult blk a -> a)
-> (forall a. IteratorResult blk a -> [a])
-> (forall a. IteratorResult blk a -> Bool)
-> (forall a. IteratorResult blk a -> Int)
-> (forall a. Eq a => a -> IteratorResult blk a -> Bool)
-> (forall a. Ord a => IteratorResult blk a -> a)
-> (forall a. Ord a => IteratorResult blk a -> a)
-> (forall a. Num a => IteratorResult blk a -> a)
-> (forall a. Num a => IteratorResult blk a -> a)
-> Foldable (IteratorResult blk)
forall a. Eq a => a -> IteratorResult blk a -> Bool
forall a. Num a => IteratorResult blk a -> a
forall a. Ord a => IteratorResult blk a -> a
forall m. Monoid m => IteratorResult blk m -> m
forall a. IteratorResult blk a -> Bool
forall a. IteratorResult blk a -> Int
forall a. IteratorResult blk a -> [a]
forall a. (a -> a -> a) -> IteratorResult blk a -> a
forall blk a. Eq a => a -> IteratorResult blk a -> Bool
forall blk a. Num a => IteratorResult blk a -> a
forall blk a. Ord a => IteratorResult blk a -> a
forall m a. Monoid m => (a -> m) -> IteratorResult blk a -> m
forall blk m. Monoid m => IteratorResult blk m -> m
forall blk a. IteratorResult blk a -> Bool
forall blk a. IteratorResult blk a -> Int
forall blk a. IteratorResult blk a -> [a]
forall b a. (b -> a -> b) -> b -> IteratorResult blk a -> b
forall a b. (a -> b -> b) -> b -> IteratorResult blk a -> b
forall blk a. (a -> a -> a) -> IteratorResult blk a -> a
forall blk m a. Monoid m => (a -> m) -> IteratorResult blk a -> m
forall blk b a. (b -> a -> b) -> b -> IteratorResult blk a -> b
forall blk a b. (a -> b -> b) -> b -> IteratorResult blk a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall blk m. Monoid m => IteratorResult blk m -> m
fold :: forall m. Monoid m => IteratorResult blk m -> m
$cfoldMap :: forall blk m a. Monoid m => (a -> m) -> IteratorResult blk a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> IteratorResult blk a -> m
$cfoldMap' :: forall blk m a. Monoid m => (a -> m) -> IteratorResult blk a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> IteratorResult blk a -> m
$cfoldr :: forall blk a b. (a -> b -> b) -> b -> IteratorResult blk a -> b
foldr :: forall a b. (a -> b -> b) -> b -> IteratorResult blk a -> b
$cfoldr' :: forall blk a b. (a -> b -> b) -> b -> IteratorResult blk a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> IteratorResult blk a -> b
$cfoldl :: forall blk b a. (b -> a -> b) -> b -> IteratorResult blk a -> b
foldl :: forall b a. (b -> a -> b) -> b -> IteratorResult blk a -> b
$cfoldl' :: forall blk b a. (b -> a -> b) -> b -> IteratorResult blk a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> IteratorResult blk a -> b
$cfoldr1 :: forall blk a. (a -> a -> a) -> IteratorResult blk a -> a
foldr1 :: forall a. (a -> a -> a) -> IteratorResult blk a -> a
$cfoldl1 :: forall blk a. (a -> a -> a) -> IteratorResult blk a -> a
foldl1 :: forall a. (a -> a -> a) -> IteratorResult blk a -> a
$ctoList :: forall blk a. IteratorResult blk a -> [a]
toList :: forall a. IteratorResult blk a -> [a]
$cnull :: forall blk a. IteratorResult blk a -> Bool
null :: forall a. IteratorResult blk a -> Bool
$clength :: forall blk a. IteratorResult blk a -> Int
length :: forall a. IteratorResult blk a -> Int
$celem :: forall blk a. Eq a => a -> IteratorResult blk a -> Bool
elem :: forall a. Eq a => a -> IteratorResult blk a -> Bool
$cmaximum :: forall blk a. Ord a => IteratorResult blk a -> a
maximum :: forall a. Ord a => IteratorResult blk a -> a
$cminimum :: forall blk a. Ord a => IteratorResult blk a -> a
minimum :: forall a. Ord a => IteratorResult blk a -> a
$csum :: forall blk a. Num a => IteratorResult blk a -> a
sum :: forall a. Num a => IteratorResult blk a -> a
$cproduct :: forall blk a. Num a => IteratorResult blk a -> a
product :: forall a. Num a => IteratorResult blk a -> a
Foldable, Functor (IteratorResult blk)
Foldable (IteratorResult blk)
(Functor (IteratorResult blk), Foldable (IteratorResult blk)) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> IteratorResult blk a -> f (IteratorResult blk b))
-> (forall (f :: * -> *) a.
Applicative f =>
IteratorResult blk (f a) -> f (IteratorResult blk a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> IteratorResult blk a -> m (IteratorResult blk b))
-> (forall (m :: * -> *) a.
Monad m =>
IteratorResult blk (m a) -> m (IteratorResult blk a))
-> Traversable (IteratorResult blk)
forall blk. Functor (IteratorResult blk)
forall blk. Foldable (IteratorResult blk)
forall blk (m :: * -> *) a.
Monad m =>
IteratorResult blk (m a) -> m (IteratorResult blk a)
forall blk (f :: * -> *) a.
Applicative f =>
IteratorResult blk (f a) -> f (IteratorResult blk a)
forall blk (m :: * -> *) a b.
Monad m =>
(a -> m b) -> IteratorResult blk a -> m (IteratorResult blk b)
forall blk (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> IteratorResult blk a -> f (IteratorResult blk b)
forall (t :: * -> *).
(Functor t, Foldable t) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
IteratorResult blk (m a) -> m (IteratorResult blk a)
forall (f :: * -> *) a.
Applicative f =>
IteratorResult blk (f a) -> f (IteratorResult blk a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> IteratorResult blk a -> m (IteratorResult blk b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> IteratorResult blk a -> f (IteratorResult blk b)
$ctraverse :: forall blk (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> IteratorResult blk a -> f (IteratorResult blk b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> IteratorResult blk a -> f (IteratorResult blk b)
$csequenceA :: forall blk (f :: * -> *) a.
Applicative f =>
IteratorResult blk (f a) -> f (IteratorResult blk a)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
IteratorResult blk (f a) -> f (IteratorResult blk a)
$cmapM :: forall blk (m :: * -> *) a b.
Monad m =>
(a -> m b) -> IteratorResult blk a -> m (IteratorResult blk b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> IteratorResult blk a -> m (IteratorResult blk b)
$csequence :: forall blk (m :: * -> *) a.
Monad m =>
IteratorResult blk (m a) -> m (IteratorResult blk a)
sequence :: forall (m :: * -> *) a.
Monad m =>
IteratorResult blk (m a) -> m (IteratorResult blk a)
Traversable)
deriving instance (Eq blk, Eq b, StandardHash blk)
=> Eq (IteratorResult blk b)
deriving instance (Show blk, Show b, StandardHash blk)
=> Show (IteratorResult blk b)
data UnknownRange blk =
MissingBlock (RealPoint blk)
| ForkTooOld (StreamFrom blk)
deriving (UnknownRange blk -> UnknownRange blk -> Bool
(UnknownRange blk -> UnknownRange blk -> Bool)
-> (UnknownRange blk -> UnknownRange blk -> Bool)
-> Eq (UnknownRange blk)
forall blk.
StandardHash blk =>
UnknownRange blk -> UnknownRange blk -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall blk.
StandardHash blk =>
UnknownRange blk -> UnknownRange blk -> Bool
== :: UnknownRange blk -> UnknownRange blk -> Bool
$c/= :: forall blk.
StandardHash blk =>
UnknownRange blk -> UnknownRange blk -> Bool
/= :: UnknownRange blk -> UnknownRange blk -> Bool
Eq, Int -> UnknownRange blk -> ShowS
[UnknownRange blk] -> ShowS
UnknownRange blk -> String
(Int -> UnknownRange blk -> ShowS)
-> (UnknownRange blk -> String)
-> ([UnknownRange blk] -> ShowS)
-> Show (UnknownRange blk)
forall blk. StandardHash blk => Int -> UnknownRange blk -> ShowS
forall blk. StandardHash blk => [UnknownRange blk] -> ShowS
forall blk. StandardHash blk => UnknownRange blk -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall blk. StandardHash blk => Int -> UnknownRange blk -> ShowS
showsPrec :: Int -> UnknownRange blk -> ShowS
$cshow :: forall blk. StandardHash blk => UnknownRange blk -> String
show :: UnknownRange blk -> String
$cshowList :: forall blk. StandardHash blk => [UnknownRange blk] -> ShowS
showList :: [UnknownRange blk] -> ShowS
Show)
streamAll ::
(MonadSTM m, HasHeader blk, HasCallStack)
=> ChainDB m blk
-> ResourceRegistry m
-> BlockComponent blk b
-> m (Iterator m blk b)
streamAll :: forall (m :: * -> *) blk b.
(MonadSTM m, HasHeader blk, HasCallStack) =>
ChainDB m blk
-> ResourceRegistry m
-> BlockComponent blk b
-> m (Iterator m blk b)
streamAll = StreamFrom blk
-> ChainDB m blk
-> ResourceRegistry m
-> BlockComponent blk b
-> m (Iterator m blk b)
forall (m :: * -> *) blk b.
(MonadSTM m, HasHeader blk, HasCallStack) =>
StreamFrom blk
-> ChainDB m blk
-> ResourceRegistry m
-> BlockComponent blk b
-> m (Iterator m blk b)
streamFrom (Point blk -> StreamFrom blk
forall blk. Point blk -> StreamFrom blk
StreamFromExclusive Point blk
forall {k} (block :: k). Point block
GenesisPoint)
streamFrom ::
(MonadSTM m, HasHeader blk, HasCallStack)
=> StreamFrom blk
-> ChainDB m blk
-> ResourceRegistry m
-> BlockComponent blk b
-> m (Iterator m blk b)
streamFrom :: forall (m :: * -> *) blk b.
(MonadSTM m, HasHeader blk, HasCallStack) =>
StreamFrom blk
-> ChainDB m blk
-> ResourceRegistry m
-> BlockComponent blk b
-> m (Iterator m blk b)
streamFrom StreamFrom blk
from ChainDB m blk
db ResourceRegistry m
registry BlockComponent blk b
blockComponent = do
Point blk
tip <- STM m (Point blk) -> m (Point blk)
forall a. HasCallStack => STM m a -> m a
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (STM m (Point blk) -> m (Point blk))
-> STM m (Point blk) -> m (Point blk)
forall a b. (a -> b) -> a -> b
$ ChainDB m blk -> STM m (Point blk)
forall (m :: * -> *) blk. ChainDB m blk -> STM m (Point blk)
getTipPoint ChainDB m blk
db
case Point blk -> WithOrigin (RealPoint blk)
forall blk. Point blk -> WithOrigin (RealPoint blk)
pointToWithOriginRealPoint Point blk
tip of
WithOrigin (RealPoint blk)
Origin -> Iterator m blk b -> m (Iterator m blk b)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Iterator m blk b
forall (m :: * -> *) blk b. Monad m => Iterator m blk b
emptyIterator
NotOrigin RealPoint blk
tip' -> do
Either (UnknownRange blk) (Iterator m blk b)
errIt <- ChainDB m blk
-> forall b.
ResourceRegistry m
-> BlockComponent blk b
-> StreamFrom blk
-> StreamTo blk
-> m (Either (UnknownRange blk) (Iterator m blk b))
forall (m :: * -> *) blk.
ChainDB m blk
-> forall b.
ResourceRegistry m
-> BlockComponent blk b
-> StreamFrom blk
-> StreamTo blk
-> m (Either (UnknownRange blk) (Iterator m blk b))
stream
ChainDB m blk
db
ResourceRegistry m
registry
BlockComponent blk b
blockComponent
StreamFrom blk
from
(RealPoint blk -> StreamTo blk
forall blk. RealPoint blk -> StreamTo blk
StreamToInclusive RealPoint blk
tip')
case Either (UnknownRange blk) (Iterator m blk b)
errIt of
Right Iterator m blk b
it -> Iterator m blk b -> m (Iterator m blk b)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Iterator m blk b
it
Left UnknownRange blk
e -> String -> m (Iterator m blk b)
forall a. HasCallStack => String -> a
error (String -> m (Iterator m blk b)) -> String -> m (Iterator m blk b)
forall a b. (a -> b) -> a -> b
$ String
"failed to stream from genesis to tip: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> UnknownRange blk -> String
forall a. Show a => a -> String
show UnknownRange blk
e
data ChainType = SelectedChain | TentativeChain
deriving (ChainType -> ChainType -> Bool
(ChainType -> ChainType -> Bool)
-> (ChainType -> ChainType -> Bool) -> Eq ChainType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChainType -> ChainType -> Bool
== :: ChainType -> ChainType -> Bool
$c/= :: ChainType -> ChainType -> Bool
/= :: ChainType -> ChainType -> Bool
Eq, Int -> ChainType -> ShowS
[ChainType] -> ShowS
ChainType -> String
(Int -> ChainType -> ShowS)
-> (ChainType -> String)
-> ([ChainType] -> ShowS)
-> Show ChainType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChainType -> ShowS
showsPrec :: Int -> ChainType -> ShowS
$cshow :: ChainType -> String
show :: ChainType -> String
$cshowList :: [ChainType] -> ShowS
showList :: [ChainType] -> ShowS
Show, (forall x. ChainType -> Rep ChainType x)
-> (forall x. Rep ChainType x -> ChainType) -> Generic ChainType
forall x. Rep ChainType x -> ChainType
forall x. ChainType -> Rep ChainType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ChainType -> Rep ChainType x
from :: forall x. ChainType -> Rep ChainType x
$cto :: forall x. Rep ChainType x -> ChainType
to :: forall x. Rep ChainType x -> ChainType
Generic)
data Follower m blk a = Follower {
forall (m :: * -> *) blk a.
Follower m blk a -> m (Maybe (ChainUpdate blk a))
followerInstruction :: m (Maybe (ChainUpdate blk a))
, forall (m :: * -> *) blk a.
Follower m blk a -> m (ChainUpdate blk a)
followerInstructionBlocking :: m (ChainUpdate blk a)
, forall (m :: * -> *) blk a.
Follower m blk a -> [Point blk] -> m (Maybe (Point blk))
followerForward :: [Point blk] -> m (Maybe (Point blk))
, forall (m :: * -> *) blk a. Follower m blk a -> m ()
followerClose :: m ()
}
deriving ((forall a b. (a -> b) -> Follower m blk a -> Follower m blk b)
-> (forall a b. a -> Follower m blk b -> Follower m blk a)
-> Functor (Follower m blk)
forall a b. a -> Follower m blk b -> Follower m blk a
forall a b. (a -> b) -> Follower m blk a -> Follower m blk b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
forall (m :: * -> *) blk a b.
Functor m =>
a -> Follower m blk b -> Follower m blk a
forall (m :: * -> *) blk a b.
Functor m =>
(a -> b) -> Follower m blk a -> Follower m blk b
$cfmap :: forall (m :: * -> *) blk a b.
Functor m =>
(a -> b) -> Follower m blk a -> Follower m blk b
fmap :: forall a b. (a -> b) -> Follower m blk a -> Follower m blk b
$c<$ :: forall (m :: * -> *) blk a b.
Functor m =>
a -> Follower m blk b -> Follower m blk a
<$ :: forall a b. a -> Follower m blk b -> Follower m blk a
Functor)
traverseFollower ::
Monad m
=> (b -> m b')
-> Follower m blk b
-> Follower m blk b'
traverseFollower :: forall (m :: * -> *) b b' blk.
Monad m =>
(b -> m b') -> Follower m blk b -> Follower m blk b'
traverseFollower b -> m b'
f Follower m blk b
flr = Follower
{ followerInstruction :: m (Maybe (ChainUpdate blk b'))
followerInstruction = Follower m blk b -> m (Maybe (ChainUpdate blk b))
forall (m :: * -> *) blk a.
Follower m blk a -> m (Maybe (ChainUpdate blk a))
followerInstruction Follower m blk b
flr m (Maybe (ChainUpdate blk b))
-> (Maybe (ChainUpdate blk b) -> m (Maybe (ChainUpdate blk b')))
-> m (Maybe (ChainUpdate blk b'))
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ChainUpdate blk b -> m (ChainUpdate blk b'))
-> Maybe (ChainUpdate blk b) -> m (Maybe (ChainUpdate blk b'))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Maybe a -> f (Maybe b)
traverse ((b -> m b') -> ChainUpdate blk b -> m (ChainUpdate blk b')
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ChainUpdate blk a -> f (ChainUpdate blk b)
traverse b -> m b'
f)
, followerInstructionBlocking :: m (ChainUpdate blk b')
followerInstructionBlocking = Follower m blk b -> m (ChainUpdate blk b)
forall (m :: * -> *) blk a.
Follower m blk a -> m (ChainUpdate blk a)
followerInstructionBlocking Follower m blk b
flr m (ChainUpdate blk b)
-> (ChainUpdate blk b -> m (ChainUpdate blk b'))
-> m (ChainUpdate blk b')
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (b -> m b') -> ChainUpdate blk b -> m (ChainUpdate blk b')
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ChainUpdate blk a -> f (ChainUpdate blk b)
traverse b -> m b'
f
, followerForward :: [Point blk] -> m (Maybe (Point blk))
followerForward = Follower m blk b -> [Point blk] -> m (Maybe (Point blk))
forall (m :: * -> *) blk a.
Follower m blk a -> [Point blk] -> m (Maybe (Point blk))
followerForward Follower m blk b
flr
, followerClose :: m ()
followerClose = Follower m blk b -> m ()
forall (m :: * -> *) blk a. Follower m blk a -> m ()
followerClose Follower m blk b
flr
}
data ChainDbFailure blk =
LgrDbFailure FsError
| ChainDbMissingBlock (RealPoint blk)
deriving (Typeable)
deriving instance StandardHash blk => Show (ChainDbFailure blk)
instance (Typeable blk, StandardHash blk) => Exception (ChainDbFailure blk) where
displayException :: ChainDbFailure blk -> String
displayException = \case
LgrDbFailure FsError
fse -> FsError -> String
fsError FsError
fse
ChainDbMissingBlock {} -> String
corruption
where
corruption :: String
corruption =
String
"The database got corrupted, full validation will be enabled for the next startup"
fsError :: FsError -> String
fsError :: FsError -> String
fsError = FsError -> String
forall e. Exception e => e -> String
displayException
data ChainDbError blk =
ClosedDBError PrettyCallStack
| ClosedFollowerError
| InvalidIteratorRange (StreamFrom blk) (StreamTo blk)
deriving (Typeable)
deriving instance (Typeable blk, StandardHash blk) => Show (ChainDbError blk)
instance (Typeable blk, StandardHash blk) => Exception (ChainDbError blk) where
displayException :: ChainDbError blk -> String
displayException = \case
ClosedDBError {} ->
String
"The database was used after it was closed because it encountered an unrecoverable error"
ClosedFollowerError {} ->
String
"The block/header follower was used after it was closed"
InvalidIteratorRange {} ->
String
"An invalid range of blocks was requested"
data LoE a =
LoEDisabled
|
LoEEnabled !a
deriving (LoE a -> LoE a -> Bool
(LoE a -> LoE a -> Bool) -> (LoE a -> LoE a -> Bool) -> Eq (LoE a)
forall a. Eq a => LoE a -> LoE a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => LoE a -> LoE a -> Bool
== :: LoE a -> LoE a -> Bool
$c/= :: forall a. Eq a => LoE a -> LoE a -> Bool
/= :: LoE a -> LoE a -> Bool
Eq, Int -> LoE a -> ShowS
[LoE a] -> ShowS
LoE a -> String
(Int -> LoE a -> ShowS)
-> (LoE a -> String) -> ([LoE a] -> ShowS) -> Show (LoE a)
forall a. Show a => Int -> LoE a -> ShowS
forall a. Show a => [LoE a] -> ShowS
forall a. Show a => LoE a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> LoE a -> ShowS
showsPrec :: Int -> LoE a -> ShowS
$cshow :: forall a. Show a => LoE a -> String
show :: LoE a -> String
$cshowList :: forall a. Show a => [LoE a] -> ShowS
showList :: [LoE a] -> ShowS
Show, (forall x. LoE a -> Rep (LoE a) x)
-> (forall x. Rep (LoE a) x -> LoE a) -> Generic (LoE a)
forall x. Rep (LoE a) x -> LoE a
forall x. LoE a -> Rep (LoE a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (LoE a) x -> LoE a
forall a x. LoE a -> Rep (LoE a) x
$cfrom :: forall a x. LoE a -> Rep (LoE a) x
from :: forall x. LoE a -> Rep (LoE a) x
$cto :: forall a x. Rep (LoE a) x -> LoE a
to :: forall x. Rep (LoE a) x -> LoE a
Generic, Context -> LoE a -> IO (Maybe ThunkInfo)
Proxy (LoE a) -> String
(Context -> LoE a -> IO (Maybe ThunkInfo))
-> (Context -> LoE a -> IO (Maybe ThunkInfo))
-> (Proxy (LoE a) -> String)
-> NoThunks (LoE a)
forall a. NoThunks a => Context -> LoE a -> IO (Maybe ThunkInfo)
forall a. NoThunks a => Proxy (LoE a) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: forall a. NoThunks a => Context -> LoE a -> IO (Maybe ThunkInfo)
noThunks :: Context -> LoE a -> IO (Maybe ThunkInfo)
$cwNoThunks :: forall a. NoThunks a => Context -> LoE a -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> LoE a -> IO (Maybe ThunkInfo)
$cshowTypeOf :: forall a. NoThunks a => Proxy (LoE a) -> String
showTypeOf :: Proxy (LoE a) -> String
NoThunks, (forall a b. (a -> b) -> LoE a -> LoE b)
-> (forall a b. a -> LoE b -> LoE a) -> Functor LoE
forall a b. a -> LoE b -> LoE a
forall a b. (a -> b) -> LoE a -> LoE b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> LoE a -> LoE b
fmap :: forall a b. (a -> b) -> LoE a -> LoE b
$c<$ :: forall a b. a -> LoE b -> LoE a
<$ :: forall a b. a -> LoE b -> LoE a
Functor, (forall m. Monoid m => LoE m -> m)
-> (forall m a. Monoid m => (a -> m) -> LoE a -> m)
-> (forall m a. Monoid m => (a -> m) -> LoE a -> m)
-> (forall a b. (a -> b -> b) -> b -> LoE a -> b)
-> (forall a b. (a -> b -> b) -> b -> LoE a -> b)
-> (forall b a. (b -> a -> b) -> b -> LoE a -> b)
-> (forall b a. (b -> a -> b) -> b -> LoE a -> b)
-> (forall a. (a -> a -> a) -> LoE a -> a)
-> (forall a. (a -> a -> a) -> LoE a -> a)
-> (forall a. LoE a -> [a])
-> (forall a. LoE a -> Bool)
-> (forall a. LoE a -> Int)
-> (forall a. Eq a => a -> LoE a -> Bool)
-> (forall a. Ord a => LoE a -> a)
-> (forall a. Ord a => LoE a -> a)
-> (forall a. Num a => LoE a -> a)
-> (forall a. Num a => LoE a -> a)
-> Foldable LoE
forall a. Eq a => a -> LoE a -> Bool
forall a. Num a => LoE a -> a
forall a. Ord a => LoE a -> a
forall m. Monoid m => LoE m -> m
forall a. LoE a -> Bool
forall a. LoE a -> Int
forall a. LoE a -> [a]
forall a. (a -> a -> a) -> LoE a -> a
forall m a. Monoid m => (a -> m) -> LoE a -> m
forall b a. (b -> a -> b) -> b -> LoE a -> b
forall a b. (a -> b -> b) -> b -> LoE a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall m. Monoid m => LoE m -> m
fold :: forall m. Monoid m => LoE m -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> LoE a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> LoE a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> LoE a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> LoE a -> m
$cfoldr :: forall a b. (a -> b -> b) -> b -> LoE a -> b
foldr :: forall a b. (a -> b -> b) -> b -> LoE a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> LoE a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> LoE a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> LoE a -> b
foldl :: forall b a. (b -> a -> b) -> b -> LoE a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> LoE a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> LoE a -> b
$cfoldr1 :: forall a. (a -> a -> a) -> LoE a -> a
foldr1 :: forall a. (a -> a -> a) -> LoE a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> LoE a -> a
foldl1 :: forall a. (a -> a -> a) -> LoE a -> a
$ctoList :: forall a. LoE a -> [a]
toList :: forall a. LoE a -> [a]
$cnull :: forall a. LoE a -> Bool
null :: forall a. LoE a -> Bool
$clength :: forall a. LoE a -> Int
length :: forall a. LoE a -> Int
$celem :: forall a. Eq a => a -> LoE a -> Bool
elem :: forall a. Eq a => a -> LoE a -> Bool
$cmaximum :: forall a. Ord a => LoE a -> a
maximum :: forall a. Ord a => LoE a -> a
$cminimum :: forall a. Ord a => LoE a -> a
minimum :: forall a. Ord a => LoE a -> a
$csum :: forall a. Num a => LoE a -> a
sum :: forall a. Num a => LoE a -> a
$cproduct :: forall a. Num a => LoE a -> a
product :: forall a. Num a => LoE a -> a
Foldable, Functor LoE
Foldable LoE
(Functor LoE, Foldable LoE) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> LoE a -> f (LoE b))
-> (forall (f :: * -> *) a.
Applicative f =>
LoE (f a) -> f (LoE a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> LoE a -> m (LoE b))
-> (forall (m :: * -> *) a. Monad m => LoE (m a) -> m (LoE a))
-> Traversable LoE
forall (t :: * -> *).
(Functor t, Foldable t) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => LoE (m a) -> m (LoE a)
forall (f :: * -> *) a. Applicative f => LoE (f a) -> f (LoE a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> LoE a -> m (LoE b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> LoE a -> f (LoE b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> LoE a -> f (LoE b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> LoE a -> f (LoE b)
$csequenceA :: forall (f :: * -> *) a. Applicative f => LoE (f a) -> f (LoE a)
sequenceA :: forall (f :: * -> *) a. Applicative f => LoE (f a) -> f (LoE a)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> LoE a -> m (LoE b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> LoE a -> m (LoE b)
$csequence :: forall (m :: * -> *) a. Monad m => LoE (m a) -> m (LoE a)
sequence :: forall (m :: * -> *) a. Monad m => LoE (m a) -> m (LoE a)
Traversable)
type GetLoEFragment m blk = m (LoE (AnchoredFragment (Header blk)))