Copyright | © 2022 IOHK |
---|---|
License | Apache-2.0 |
Safe Haskell | None |
Language | Haskell2010 |
This module provides the
BlockSummary
type
which summarizes a contiguous sequence of blocks.
Synopsis
-
data
BlockSummary
m addr txs =
BlockSummary
{
- from :: ! BlockHeader
- to :: ! BlockHeader
- query :: addr -> m txs
- type LightSummary m = BlockSummary m ( Either Address RewardAccount ) ChainEvents
- data ChainEvents
- fromBlockEvents :: [ BlockEvents ] -> ChainEvents
- toAscBlockEvents :: ChainEvents -> [ BlockEvents ]
-
data
BlockEvents
=
BlockEvents
{
- slot :: ! Slot
- blockHeight :: !( Quantity "block" Word32 )
- transactions :: Sublist Tx
- delegations :: Sublist DelegationCertificate
- fromEntireBlock :: Block -> BlockEvents
- data Sublist a
- filterSublist :: (a -> Bool ) -> Sublist a -> Sublist a
- wholeList :: [a] -> Sublist a
- summarizeOnTxOut :: NonEmpty Block -> LightSummary Identity
- mkChainEvents :: Map Slot BlockEvents -> ChainEvents
- mergeSublist :: Sublist a -> Sublist a -> Sublist a
- unsafeMkSublist :: [((Index1, Index2), a)] -> Sublist a
Documentation
data BlockSummary m addr txs Source #
A
BlockSummary
summarizes the data contained in a contiguous sequence
of blocks.
However, instead of storing the sequence of blocks of directly as a Haskell
list, the
BlockSummary
only provides a
$sel:query:BlockSummary
function
which looks up all transactions associated to a given addresses.
In addition, this query function is monadic, which means that it
can call out to an external data source.
BlockSummary | |
|
Instances
Generic ( BlockSummary m addr txs) Source # | |
Defined in Cardano.Wallet.Primitive.BlockSummary from :: BlockSummary m addr txs -> Rep ( BlockSummary m addr txs) x Source # to :: Rep ( BlockSummary m addr txs) x -> BlockSummary m addr txs Source # |
|
type Rep ( BlockSummary m addr txs) Source # | |
Defined in Cardano.Wallet.Primitive.BlockSummary
type
Rep
(
BlockSummary
m addr txs) =
D1
('
MetaData
"BlockSummary" "Cardano.Wallet.Primitive.BlockSummary" "cardano-wallet-core-2022.7.1-AGKhlyz9liLKN3QqZD1gj" '
False
) (
C1
('
MetaCons
"BlockSummary" '
PrefixI
'
True
) (
S1
('
MetaSel
('
Just
"from") '
NoSourceUnpackedness
'
SourceStrict
'
DecidedStrict
) (
Rec0
BlockHeader
)
:*:
(
S1
('
MetaSel
('
Just
"to") '
NoSourceUnpackedness
'
SourceStrict
'
DecidedStrict
) (
Rec0
BlockHeader
)
:*:
S1
('
MetaSel
('
Just
"query") '
NoSourceUnpackedness
'
NoSourceStrictness
'
DecidedLazy
) (
Rec0
(addr -> m txs)))))
|
type LightSummary m = BlockSummary m ( Either Address RewardAccount ) ChainEvents Source #
BlockSummary
used for light-mode.
Chain Events
data ChainEvents Source #
BlockEvents
, always ordered by slot.
Instances
fromBlockEvents :: [ BlockEvents ] -> ChainEvents Source #
Create
ChainEvents
from a list of block events
(which do not need to be in order.)
toAscBlockEvents :: ChainEvents -> [ BlockEvents ] Source #
List of
BlockEvents
, in ascending order.
(No duplicate blocks, all transactions within block in order).
Block Events
data BlockEvents Source #
Events (such as txs, delegations) within a single block that are potentially relevant to the wallet. This can be the entire block, or a pre-filtered version of it.
BlockEvents | |
|
Instances
fromEntireBlock :: Block -> BlockEvents Source #
Get the
BlockEvents
corresponding to an entire
Block
.
Sublist
A data type representing a sublist of a total list. Such a sublist typically arises by filtering and keeps track of the indices of the filtered list elements.
In order to represent sublists of
DelegationCertificate
,
we do not use a single
Int
, but a pair
(Index1,Index2)
as index internally.
This internal index is not part of the (safe) API of
Sublist
.
The main purpose of this data type is optimization:
When processing whole
Block
, we want to avoid copying
and redecorating the entire list of transactions in that
Block
;
instead, we want to copy a pointer to this list.
Instances
Functor Sublist Source # | |
Foldable Sublist Source # | |
Defined in Cardano.Wallet.Primitive.BlockSummary fold :: Monoid m => Sublist m -> m Source # foldMap :: Monoid m => (a -> m) -> Sublist a -> m Source # foldMap' :: Monoid m => (a -> m) -> Sublist a -> m Source # foldr :: (a -> b -> b) -> b -> Sublist a -> b Source # foldr' :: (a -> b -> b) -> b -> Sublist a -> b Source # foldl :: (b -> a -> b) -> b -> Sublist a -> b Source # foldl' :: (b -> a -> b) -> b -> Sublist a -> b Source # foldr1 :: (a -> a -> a) -> Sublist a -> a Source # foldl1 :: (a -> a -> a) -> Sublist a -> a Source # toList :: Sublist a -> [a] Source # null :: Sublist a -> Bool Source # length :: Sublist a -> Int Source # elem :: Eq a => a -> Sublist a -> Bool Source # maximum :: Ord a => Sublist a -> a Source # minimum :: Ord a => Sublist a -> a Source # |
|
Eq a => Eq ( Sublist a) Source # | |
Ord a => Ord ( Sublist a) Source # | |
Defined in Cardano.Wallet.Primitive.BlockSummary |
|
Show a => Show ( Sublist a) Source # | |
Internal & Testing
summarizeOnTxOut :: NonEmpty Block -> LightSummary Identity Source #
For testing:
Convert a list of blocks into a
BlockSummary
.
Unfortunately, as
TxIn
references are not resolved,
we can only find transactions with relevant
TxOut
.
mergeSublist :: Sublist a -> Sublist a -> Sublist a Source #
Merge two
Sublist
assuming that they are sublists of the
same
list.
unsafeMkSublist :: [((Index1, Index2), a)] -> Sublist a Source #
Construct a
Sublist
from a list of indexed items.