plutus-chain-index-core-1.2.0.0
Safe Haskell None
Language Haskell2010

Plutus.ChainIndex.UtxoState

Description

The UTXO state, kept in memory by the chain index.

Synopsis

Documentation

data UtxoState a Source #

UTXO / ledger state, kept in memory. We are only interested in the UTXO set, everything else is stored on disk. This is OK because we don't need to validate transactions when they come in.

Constructors

UtxoState

Fields

Instances

Instances details
Eq a => Eq ( UtxoState a) Source #
Instance details

Defined in Plutus.ChainIndex.UtxoState

Eq a => Ord ( UtxoState a) Source #
Instance details

Defined in Plutus.ChainIndex.UtxoState

Show a => Show ( UtxoState a) Source #
Instance details

Defined in Plutus.ChainIndex.UtxoState

Generic ( UtxoState a) Source #
Instance details

Defined in Plutus.ChainIndex.UtxoState

Associated Types

type Rep ( UtxoState a) :: Type -> Type Source #

Semigroup a => Semigroup ( UtxoState a) Source #
Instance details

Defined in Plutus.ChainIndex.UtxoState

Monoid a => Monoid ( UtxoState a) Source #
Instance details

Defined in Plutus.ChainIndex.UtxoState

ToJSON a => ToJSON ( UtxoState a) Source #
Instance details

Defined in Plutus.ChainIndex.UtxoState

FromJSON a => FromJSON ( UtxoState a) Source #
Instance details

Defined in Plutus.ChainIndex.UtxoState

Monoid a => Measured ( BlockCount , UtxoState a) ( UtxoState a) Source #
Instance details

Defined in Plutus.ChainIndex.UtxoState

type Rep ( UtxoState a) Source #
Instance details

Defined in Plutus.ChainIndex.UtxoState

type Rep ( UtxoState a) = D1 (' MetaData "UtxoState" "Plutus.ChainIndex.UtxoState" "plutus-chain-index-core-1.2.0.0-vEgAIGWZqMIuVHBPih2W5" ' False ) ( C1 (' MetaCons "UtxoState" ' PrefixI ' True ) ( S1 (' MetaSel (' Just "_usTxUtxoData") ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedStrict ) ( Rec0 a) :*: S1 (' MetaSel (' Just "_usTip") ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedStrict ) ( Rec0 Tip )))

pointLessThanTip :: Point -> Tip -> Bool Source #

Is the given point earlier than the provided tip. Yes, if the point is the genersis point, no if the tip is the genesis point, otherwise, just compare the slots.

Extending the UTXO index

data InsertUtxoPosition Source #

Outcome of inserting a UtxoState into the utxo index

Constructors

InsertAtEnd

The utxo state was added to the end. Returns the new index

InsertBeforeEnd

The utxo state was added somewhere before the end. Returns the new index and the tip

Instances

Instances details
Eq InsertUtxoPosition Source #
Instance details

Defined in Plutus.ChainIndex.ChainIndexLog

Ord InsertUtxoPosition Source #
Instance details

Defined in Plutus.ChainIndex.ChainIndexLog

Show InsertUtxoPosition Source #
Instance details

Defined in Plutus.ChainIndex.ChainIndexLog

Generic InsertUtxoPosition Source #
Instance details

Defined in Plutus.ChainIndex.ChainIndexLog

ToJSON InsertUtxoPosition Source #
Instance details

Defined in Plutus.ChainIndex.ChainIndexLog

FromJSON InsertUtxoPosition Source #
Instance details

Defined in Plutus.ChainIndex.ChainIndexLog

Pretty InsertUtxoPosition Source #
Instance details

Defined in Plutus.ChainIndex.ChainIndexLog

type Rep InsertUtxoPosition Source #
Instance details

Defined in Plutus.ChainIndex.ChainIndexLog

type Rep InsertUtxoPosition = D1 (' MetaData "InsertUtxoPosition" "Plutus.ChainIndex.ChainIndexLog" "plutus-chain-index-core-1.2.0.0-vEgAIGWZqMIuVHBPih2W5" ' False ) ( C1 (' MetaCons "InsertAtEnd" ' PrefixI ' False ) ( U1 :: Type -> Type ) :+: C1 (' MetaCons "InsertBeforeEnd" ' PrefixI ' False ) ( U1 :: Type -> Type ))

data InsertUtxoFailed Source #

UTXO state could not be inserted into the chain index

Constructors

DuplicateBlock Tip

Insertion failed as there was already a block with the given number

InsertUtxoNoTip

The _usTip field of the argument was 'Last Nothing'

Instances

Instances details
Eq InsertUtxoFailed Source #
Instance details

Defined in Plutus.ChainIndex.ChainIndexError

Ord InsertUtxoFailed Source #
Instance details

Defined in Plutus.ChainIndex.ChainIndexError

Show InsertUtxoFailed Source #
Instance details

Defined in Plutus.ChainIndex.ChainIndexError

Generic InsertUtxoFailed Source #
Instance details

Defined in Plutus.ChainIndex.ChainIndexError

ToJSON InsertUtxoFailed Source #
Instance details

Defined in Plutus.ChainIndex.ChainIndexError

FromJSON InsertUtxoFailed Source #
Instance details

Defined in Plutus.ChainIndex.ChainIndexError

Pretty InsertUtxoFailed Source #
Instance details

Defined in Plutus.ChainIndex.ChainIndexError

type Rep InsertUtxoFailed Source #
Instance details

Defined in Plutus.ChainIndex.ChainIndexError

type Rep InsertUtxoFailed = D1 (' MetaData "InsertUtxoFailed" "Plutus.ChainIndex.ChainIndexError" "plutus-chain-index-core-1.2.0.0-vEgAIGWZqMIuVHBPih2W5" ' False ) ( C1 (' MetaCons "DuplicateBlock" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 Tip )) :+: C1 (' MetaCons "InsertUtxoNoTip" ' PrefixI ' False ) ( U1 :: Type -> Type ))

Rollbacks

data RollbackFailed Source #

Reason why the rollback operation failed

Constructors

RollbackNoTip

Rollback failed because the utxo index had no tip (not synchronised)

TipMismatch

Unable to roll back to expectedTip because the tip at that position was different

OldPointNotFound Point

Unable to find the old tip

Instances

Instances details
Eq RollbackFailed Source #
Instance details

Defined in Plutus.ChainIndex.ChainIndexError

Ord RollbackFailed Source #
Instance details

Defined in Plutus.ChainIndex.ChainIndexError

Show RollbackFailed Source #
Instance details

Defined in Plutus.ChainIndex.ChainIndexError

Generic RollbackFailed Source #
Instance details

Defined in Plutus.ChainIndex.ChainIndexError

ToJSON RollbackFailed Source #
Instance details

Defined in Plutus.ChainIndex.ChainIndexError

FromJSON RollbackFailed Source #
Instance details

Defined in Plutus.ChainIndex.ChainIndexError

Pretty RollbackFailed Source #
Instance details

Defined in Plutus.ChainIndex.ChainIndexError

type Rep RollbackFailed Source #
Instance details

Defined in Plutus.ChainIndex.ChainIndexError

rollbackWith Source #

Arguments

:: Monoid a
=> ( UtxoIndex a -> UtxoIndex a -> UtxoIndex a)

Calculate the new index given the index before and the index after the rollback point.

-> Point
-> UtxoIndex a
-> Either RollbackFailed ( RollbackResult a)

Perform a rollback on the utxo index, with a callback to calculate the new index.

Limit the UTXO index size

reduceBlockCount :: Monoid a => Depth -> UtxoIndex a -> ReduceBlockCountResult a Source #

Reduce the number of UtxoState s. The given number is the minimum, the index is reduced when it larger than twice that size. The new index is prefixed with one UtxoState that contains the combined state of the removed UtxoState s.