ouroboros-consensus-0.26.0.0: Consensus layer for the Ouroboros blockchain protocol
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Description

Sequences of diffs for ledger tables.

These diff sequences are an instantiation of a strict finger tree with root measures. The tree/sequence itself contains diffs and slot information, while the root measure is the total sum of all diffs in the sequence. The internal measure is used to keep track of sequence length and maximum slot numbers.

The diff datatype that we use forms a cancellative monoid, which allows for relatively efficient splitting of finger trees with respect to recomputing measures by means of subtracting diffs using the stripPrefix and stripSuffix functions that cancellative monoids provide. Namely, if either the left or right part of the split is small in comparison with the input sequence, then we can subtract the diffs in the smaller part from the root measure of the input to (quickly) compute the root measure of the other part of the split. This is much faster than computing the root measures from scratch by doing a linear-time pass over the elements of the split parts, or a logarithmic-time pass over intermediate sums of diffs in case we store cumulative diffs in the nodes of the finger tree.

Example of fast splits

As an analogy, consider this example: we have a sequence of consecutive integer numbers xs = [1..n] where n is large, and we define the root measure of the sequence to be the total sum of these numbers, rmxs = sum [1..n] (we assume rmxs is fully evaluated). Say we split this sequence of integer numbers at the index 2, then we get left and right parts of the split ys and zs respectively.

splitAt 2 xs = (ys, zs) = ([1..2], [3..n])

How should we compute we the root measure rmys of ys? Since ys is small, we can just compute rmys = sum [1..2]. How should we compute the root measure rmzs of zs? We should not compute rmzs = sum [3..n] in this case, since n is large. Instead, we compute rmzs = rmxs - rmys, which evaluates to its result in time that is linear in the length of ys, in this case O(1).

Why not store sums of diffs in the internal measure instead of the root

measure?

We could also have used the interal measure of the strict finger tree to store intermediate sums of diffs for all subtrees of the node. The subtree rooted at the root of the tree would then store the total sum of diffs. However, we would have now to recompute a possibly logarithmic number of sums of diffs when we split or extend the sequence. Given that in consensus we use the total sum of diffs nearly as often as we split or extend the diff sequence, this proved to be too costly. The single-instance root measure reduces the overhead of this "caching" of intermediate sums of diffs by only using a single total sum of diffs, though augmented with stripPrefix and stripSuffix operations to facilitate computing updated root measures.

Root measures in practice

In consensus, we have the following access pattern. We perform A then B a total of n times, and then we perform C(n) once. Repeat.

A    = retrieve the total sum of diffs
B    = snoc a diff to the sequence
C(n) = split n diffs from the left of the sequence

In Cardano, n == 100 by default. That means we split roughly 2^7 diffs from a sequence of length roughly 2^11. At first glance, it seems counterintuitive that using a root measured finger tree would be quicker than using a "normal" finger tree, because the former has a split function with a linear cost. It needs to recompute the sum of 2^7 diffs, instead of 7 diffs if we were to use the normal finger tree split, which has logarithmic complexity.

We wrote a benchmark that exercises the root measured finger tree and the normal finger tree according to the described access pattern. It turned out that the root measured fingertree was faster. If we look at the complexity of these operations, then for a normal fingertree:

A      = O(1)       amortised
B      = O(1)       amortised
C(100) = O(log 100) amortised

For a root measured fingertree:

A      = O(1)   worst-case
B      = O(1)   worst-case
C(100) = O(100) worst-case

Complexity wise, the root measured finger tree looks worse, but in practice it performs a bit better than the normal finger tree. It might mean there are higher constants at play for the computational complexity of the normal finger tree operations.

TODO: I wonder if is worth it to keep using the root measured finger tree. The root measured finger tree sacrifices computational complexity for an algorithm that works well in pratice for n=100; given that the flush frequency is configurable, using a value other than 100 might lead to worse performance than if we were to use a normal finger tree.

Synopsis

Sequences of diffs

newtype DiffSeq k v Source #

A sequence of key-value store differences.

INVARIANT: The slot numbers of consecutive elements should be strictly increasing. Manipulating the underlying StrictFingerTree directly may break this invariant.

Instances

Instances details
Generic (DiffSeq k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Associated Types

type Rep (DiffSeq k v) 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

type Rep (DiffSeq k v) = D1 ('MetaData "DiffSeq" "Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq" "ouroboros-consensus-0.26.0.0-inplace" 'True) (C1 ('MetaCons "UnsafeDiffSeq" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (StrictFingerTree (RootMeasure k v) (InternalMeasure k v) (Element k v)))))

Methods

fromDiffSeq k v → Rep (DiffSeq k v) x #

toRep (DiffSeq k v) x → DiffSeq k v #

(Show k, Show v) ⇒ Show (DiffSeq k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

showsPrecIntDiffSeq k v → ShowS #

showDiffSeq k v → String #

showList ∷ [DiffSeq k v] → ShowS #

(Eq k, Eq v) ⇒ Eq (DiffSeq k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

(==)DiffSeq k v → DiffSeq k v → Bool #

(/=)DiffSeq k v → DiffSeq k v → Bool #

(NoThunks k, NoThunks v) ⇒ NoThunks (DiffSeq k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

type Rep (DiffSeq k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

type Rep (DiffSeq k v) = D1 ('MetaData "DiffSeq" "Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq" "ouroboros-consensus-0.26.0.0-inplace" 'True) (C1 ('MetaCons "UnsafeDiffSeq" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (StrictFingerTree (RootMeasure k v) (InternalMeasure k v) (Element k v)))))

data Element k v Source #

Constructors

Element 

Fields

Instances

Instances details
Functor (Element k) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

fmap ∷ (a → b) → Element k a → Element k b #

(<$) ∷ a → Element k b → Element k a #

Generic (Element k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Associated Types

type Rep (Element k v) 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

type Rep (Element k v) = D1 ('MetaData "Element" "Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq" "ouroboros-consensus-0.26.0.0-inplace" 'False) (C1 ('MetaCons "Element" 'PrefixI 'True) (S1 ('MetaSel ('Just "elSlotNo") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 SlotNo) :*: S1 ('MetaSel ('Just "elDiff") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Diff k v))))

Methods

fromElement k v → Rep (Element k v) x #

toRep (Element k v) x → Element k v #

(Show k, Show v) ⇒ Show (Element k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

showsPrecIntElement k v → ShowS #

showElement k v → String #

showList ∷ [Element k v] → ShowS #

(Eq k, Eq v) ⇒ Eq (Element k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

(==)Element k v → Element k v → Bool #

(/=)Element k v → Element k v → Bool #

(NoThunks k, NoThunks v) ⇒ NoThunks (Element k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Measured (InternalMeasure k v) (Element k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

measureElement k v → InternalMeasure k v Source #

(Ord k, Eq v) ⇒ RootMeasured (RootMeasure k v) (Element k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

measureRootElement k v → RootMeasure k v Source #

type Rep (Element k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

type Rep (Element k v) = D1 ('MetaData "Element" "Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq" "ouroboros-consensus-0.26.0.0-inplace" 'False) (C1 ('MetaCons "Element" 'PrefixI 'True) (S1 ('MetaSel ('Just "elSlotNo") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 SlotNo) :*: S1 ('MetaSel ('Just "elDiff") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Diff k v))))

data InternalMeasure k v Source #

Constructors

InternalMeasure 

Fields

  • imLength ∷ !Length

    Cumulative length

  • imSlotNoL ∷ !(StrictMaybe SlotNoLB)

    Leftmost slot number (or lower bound)

    Empty diff sequences have no rightmost slot number, so in that case imSlotNo == Nothing.

  • imSlotNoR ∷ !(StrictMaybe SlotNoUB)

    Rightmost slot number (or upper bound)

    Empty diff sequences have no leftmost slot number, so in that case imSlotNo == Nothing.

Instances

Instances details
Functor (InternalMeasure k) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

fmap ∷ (a → b) → InternalMeasure k a → InternalMeasure k b #

(<$) ∷ a → InternalMeasure k b → InternalMeasure k a #

Sized (InternalMeasure k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

sizeInternalMeasure k v → Int Source #

Monoid (InternalMeasure k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Semigroup (InternalMeasure k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Generic (InternalMeasure k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Associated Types

type Rep (InternalMeasure k v) 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

type Rep (InternalMeasure k v) = D1 ('MetaData "InternalMeasure" "Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq" "ouroboros-consensus-0.26.0.0-inplace" 'False) (C1 ('MetaCons "InternalMeasure" 'PrefixI 'True) (S1 ('MetaSel ('Just "imLength") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Length) :*: (S1 ('MetaSel ('Just "imSlotNoL") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (StrictMaybe SlotNoLB)) :*: S1 ('MetaSel ('Just "imSlotNoR") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (StrictMaybe SlotNoUB)))))

Methods

fromInternalMeasure k v → Rep (InternalMeasure k v) x #

toRep (InternalMeasure k v) x → InternalMeasure k v #

Show (InternalMeasure k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

showsPrecIntInternalMeasure k v → ShowS #

showInternalMeasure k v → String #

showList ∷ [InternalMeasure k v] → ShowS #

Eq (InternalMeasure k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

(==)InternalMeasure k v → InternalMeasure k v → Bool #

(/=)InternalMeasure k v → InternalMeasure k v → Bool #

NoThunks (InternalMeasure k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Measured (InternalMeasure k v) (Element k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

measureElement k v → InternalMeasure k v Source #

type Rep (InternalMeasure k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

type Rep (InternalMeasure k v) = D1 ('MetaData "InternalMeasure" "Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq" "ouroboros-consensus-0.26.0.0-inplace" 'False) (C1 ('MetaCons "InternalMeasure" 'PrefixI 'True) (S1 ('MetaSel ('Just "imLength") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Length) :*: (S1 ('MetaSel ('Just "imSlotNoL") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (StrictMaybe SlotNoLB)) :*: S1 ('MetaSel ('Just "imSlotNoR") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (StrictMaybe SlotNoUB)))))

newtype Length Source #

Length of a sequence of differences.

Constructors

Length 

Fields

Instances

Instances details
Monoid Length Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

memptyLength #

mappendLengthLengthLength #

mconcat ∷ [Length] → Length #

Semigroup Length Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

(<>)LengthLengthLength #

sconcatNonEmpty LengthLength #

stimesIntegral b ⇒ b → LengthLength #

Generic Length Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Associated Types

type Rep Length 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

type Rep Length = D1 ('MetaData "Length" "Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq" "ouroboros-consensus-0.26.0.0-inplace" 'True) (C1 ('MetaCons "Length" 'PrefixI 'True) (S1 ('MetaSel ('Just "unLength") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))

Methods

fromLengthRep Length x #

toRep Length x → Length #

Num Length Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

(+)LengthLengthLength #

(-)LengthLengthLength #

(*)LengthLengthLength #

negateLengthLength #

absLengthLength #

signumLengthLength #

fromIntegerIntegerLength #

Show Length Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

showsPrecIntLengthShowS #

showLengthString #

showList ∷ [Length] → ShowS #

Eq Length Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

(==)LengthLengthBool #

(/=)LengthLengthBool #

Ord Length Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

compareLengthLengthOrdering #

(<)LengthLengthBool #

(<=)LengthLengthBool #

(>)LengthLengthBool #

(>=)LengthLengthBool #

maxLengthLengthLength #

minLengthLengthLength #

LeftCancellative Length Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

LeftReductive Length Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

RightCancellative Length Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

RightReductive Length Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

NoThunks Length Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

type Rep Length Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

type Rep Length = D1 ('MetaData "Length" "Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq" "ouroboros-consensus-0.26.0.0-inplace" 'True) (C1 ('MetaCons "Length" 'PrefixI 'True) (S1 ('MetaSel ('Just "unLength") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))

data RootMeasure k v Source #

Constructors

RootMeasure 

Fields

Instances

Instances details
Functor (RootMeasure k) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

fmap ∷ (a → b) → RootMeasure k a → RootMeasure k b #

(<$) ∷ a → RootMeasure k b → RootMeasure k a #

(Ord k, Eq v) ⇒ Monoid (RootMeasure k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

memptyRootMeasure k v #

mappendRootMeasure k v → RootMeasure k v → RootMeasure k v #

mconcat ∷ [RootMeasure k v] → RootMeasure k v #

(Ord k, Eq v) ⇒ Semigroup (RootMeasure k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

(<>)RootMeasure k v → RootMeasure k v → RootMeasure k v #

sconcatNonEmpty (RootMeasure k v) → RootMeasure k v #

stimesIntegral b ⇒ b → RootMeasure k v → RootMeasure k v #

Generic (RootMeasure k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Associated Types

type Rep (RootMeasure k v) 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

type Rep (RootMeasure k v) = D1 ('MetaData "RootMeasure" "Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq" "ouroboros-consensus-0.26.0.0-inplace" 'False) (C1 ('MetaCons "RootMeasure" 'PrefixI 'True) ((S1 ('MetaSel ('Just "rmLength") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Length) :*: S1 ('MetaSel ('Just "rmDiff") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Diff k v))) :*: (S1 ('MetaSel ('Just "rmNumInserts") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Sum Int)) :*: S1 ('MetaSel ('Just "rmNumDeletes") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Sum Int)))))

Methods

fromRootMeasure k v → Rep (RootMeasure k v) x #

toRep (RootMeasure k v) x → RootMeasure k v #

(Show k, Show v) ⇒ Show (RootMeasure k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

showsPrecIntRootMeasure k v → ShowS #

showRootMeasure k v → String #

showList ∷ [RootMeasure k v] → ShowS #

(Eq k, Eq v) ⇒ Eq (RootMeasure k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

(==)RootMeasure k v → RootMeasure k v → Bool #

(/=)RootMeasure k v → RootMeasure k v → Bool #

(Ord k, Eq v) ⇒ LeftCancellative (RootMeasure k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

(Ord k, Eq v) ⇒ LeftReductive (RootMeasure k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

(Ord k, Eq v) ⇒ RightCancellative (RootMeasure k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

(Ord k, Eq v) ⇒ RightReductive (RootMeasure k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

(NoThunks k, NoThunks v) ⇒ NoThunks (RootMeasure k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

(Ord k, Eq v) ⇒ RootMeasured (RootMeasure k v) (Element k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

measureRootElement k v → RootMeasure k v Source #

type Rep (RootMeasure k v) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

type Rep (RootMeasure k v) = D1 ('MetaData "RootMeasure" "Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq" "ouroboros-consensus-0.26.0.0-inplace" 'False) (C1 ('MetaCons "RootMeasure" 'PrefixI 'True) ((S1 ('MetaSel ('Just "rmLength") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Length) :*: S1 ('MetaSel ('Just "rmDiff") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Diff k v))) :*: (S1 ('MetaSel ('Just "rmNumInserts") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Sum Int)) :*: S1 ('MetaSel ('Just "rmNumDeletes") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Sum Int)))))

newtype SlotNoLB Source #

A lower bound on slot numbers.

Constructors

SlotNoLB 

Fields

Instances

Instances details
Monoid SlotNoLB Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Semigroup SlotNoLB Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Generic SlotNoLB Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Associated Types

type Rep SlotNoLB 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

type Rep SlotNoLB = D1 ('MetaData "SlotNoLB" "Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq" "ouroboros-consensus-0.26.0.0-inplace" 'True) (C1 ('MetaCons "SlotNoLB" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSlotNoLB") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SlotNo)))

Methods

fromSlotNoLBRep SlotNoLB x #

toRep SlotNoLB x → SlotNoLB #

Num SlotNoLB Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Show SlotNoLB Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

showsPrecIntSlotNoLBShowS #

showSlotNoLBString #

showList ∷ [SlotNoLB] → ShowS #

Eq SlotNoLB Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

(==)SlotNoLBSlotNoLBBool #

(/=)SlotNoLBSlotNoLBBool #

Ord SlotNoLB Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

NoThunks SlotNoLB Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

type Rep SlotNoLB Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

type Rep SlotNoLB = D1 ('MetaData "SlotNoLB" "Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq" "ouroboros-consensus-0.26.0.0-inplace" 'True) (C1 ('MetaCons "SlotNoLB" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSlotNoLB") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SlotNo)))

newtype SlotNoUB Source #

An upper bound on slot numbers.

Constructors

SlotNoUB 

Fields

Instances

Instances details
Monoid SlotNoUB Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Semigroup SlotNoUB Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Generic SlotNoUB Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Associated Types

type Rep SlotNoUB 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

type Rep SlotNoUB = D1 ('MetaData "SlotNoUB" "Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq" "ouroboros-consensus-0.26.0.0-inplace" 'True) (C1 ('MetaCons "SlotNoUB" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSlotNoUB") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SlotNo)))

Methods

fromSlotNoUBRep SlotNoUB x #

toRep SlotNoUB x → SlotNoUB #

Num SlotNoUB Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Show SlotNoUB Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

showsPrecIntSlotNoUBShowS #

showSlotNoUBString #

showList ∷ [SlotNoUB] → ShowS #

Eq SlotNoUB Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

Methods

(==)SlotNoUBSlotNoUBBool #

(/=)SlotNoUBSlotNoUBBool #

Ord SlotNoUB Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

NoThunks SlotNoUB Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

type Rep SlotNoUB Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq

type Rep SlotNoUB = D1 ('MetaData "SlotNoUB" "Ouroboros.Consensus.Storage.LedgerDB.V1.DiffSeq" "ouroboros-consensus-0.26.0.0-inplace" 'True) (C1 ('MetaCons "SlotNoUB" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSlotNoUB") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SlotNo)))

Short-hands for type-class constraints

type SM k v = SuperMeasured (RootMeasure k v) (InternalMeasure k v) (Element k v) Source #

Short-hand for SuperMeasured.

Queries

cumulativeDiffSM k v ⇒ DiffSeq k v → Diff k v Source #

lengthSM k v ⇒ DiffSeq k v → Int Source #

numDeletesSM k v ⇒ DiffSeq k v → Sum Int Source #

numInsertsSM k v ⇒ DiffSeq k v → Sum Int Source #

Construction

append ∷ (Ord k, Eq v) ⇒ DiffSeq k v → DiffSeq k v → DiffSeq k v Source #

empty ∷ (Ord k, Eq v) ⇒ DiffSeq k v Source #

extendSM k v ⇒ DiffSeq k v → SlotNoDiff k v → DiffSeq k v Source #

Slots

Splitting

splitSM k v ⇒ (InternalMeasure k v → Bool) → DiffSeq k v → (DiffSeq k v, DiffSeq k v) Source #

splitAtSM k v ⇒ IntDiffSeq k v → (DiffSeq k v, DiffSeq k v) Source #

splitAtFromEnd ∷ (SM k v, HasCallStack) ⇒ IntDiffSeq k v → (DiffSeq k v, DiffSeq k v) Source #

splitAtSlotSM k v ⇒ SlotNoDiffSeq k v → (DiffSeq k v, DiffSeq k v) Source #

Conversion

fromAntiDiffDiff k v → Diff k v Source #

toAntiDiffDiff k v → Diff k v Source #