plutus-chain-index-core-1.2.0.0
Safe HaskellNone
LanguageHaskell2010

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 #

Methods

from :: UtxoState a -> Rep (UtxoState a) x Source #

to :: Rep (UtxoState a) x -> UtxoState a 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

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

Defined in Plutus.ChainIndex.UtxoState

Methods

parseJSON :: Value -> Parser (UtxoState a)

parseJSONList :: Value -> Parser [UtxoState a]

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

Defined in Plutus.ChainIndex.UtxoState

Methods

toJSON :: UtxoState a -> Value

toEncoding :: UtxoState a -> Encoding

toJSONList :: [UtxoState a] -> Value

toEncodingList :: [UtxoState a] -> Encoding

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-KXwe88sWnh3Kg9uXBYztrS" 'False) (C1 ('MetaCons "UtxoState" 'PrefixI 'True) (S1 ('MetaSel ('Just "_usTxUtxoData") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Just "_usTip") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Tip)))

usTxUtxoData :: forall a a. Lens (UtxoState a) (UtxoState a) a a Source #

usTip :: forall a. Lens' (UtxoState a) Tip Source #

type UtxoIndex a = FingerTree (BlockCount, UtxoState a) (UtxoState a) Source #

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

Associated Types

type Rep InsertUtxoPosition :: Type -> Type Source #

FromJSON InsertUtxoPosition Source # 
Instance details

Defined in Plutus.ChainIndex.ChainIndexLog

Methods

parseJSON :: Value -> Parser InsertUtxoPosition

parseJSONList :: Value -> Parser [InsertUtxoPosition]

ToJSON InsertUtxoPosition Source # 
Instance details

Defined in Plutus.ChainIndex.ChainIndexLog

Pretty InsertUtxoPosition Source # 
Instance details

Defined in Plutus.ChainIndex.ChainIndexLog

Methods

pretty :: InsertUtxoPosition -> Doc ann

prettyList :: [InsertUtxoPosition] -> Doc ann

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-KXwe88sWnh3Kg9uXBYztrS" 'False) (C1 ('MetaCons "InsertAtEnd" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "InsertBeforeEnd" 'PrefixI 'False) (U1 :: Type -> Type))

data InsertUtxoSuccess a Source #

Instances

Instances details
Pretty (InsertUtxoSuccess a) Source # 
Instance details

Defined in Plutus.ChainIndex.UtxoState

Methods

pretty :: InsertUtxoSuccess a -> Doc ann

prettyList :: [InsertUtxoSuccess a] -> Doc ann

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

Associated Types

type Rep InsertUtxoFailed :: Type -> Type Source #

FromJSON InsertUtxoFailed Source # 
Instance details

Defined in Plutus.ChainIndex.ChainIndexError

Methods

parseJSON :: Value -> Parser InsertUtxoFailed

parseJSONList :: Value -> Parser [InsertUtxoFailed]

ToJSON InsertUtxoFailed Source # 
Instance details

Defined in Plutus.ChainIndex.ChainIndexError

Pretty InsertUtxoFailed Source # 
Instance details

Defined in Plutus.ChainIndex.ChainIndexError

Methods

pretty :: InsertUtxoFailed -> Doc ann

prettyList :: [InsertUtxoFailed] -> Doc ann

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-KXwe88sWnh3Kg9uXBYztrS" 'False) (C1 ('MetaCons "DuplicateBlock" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Tip)) :+: C1 ('MetaCons "InsertUtxoNoTip" 'PrefixI 'False) (U1 :: Type -> Type))

insert :: (Monoid a, Eq a) => UtxoState a -> UtxoIndex a -> Either InsertUtxoFailed (InsertUtxoSuccess a) Source #

Insert a UtxoState into the index

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

Fields

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

Associated Types

type Rep RollbackFailed :: Type -> Type Source #

FromJSON RollbackFailed Source # 
Instance details

Defined in Plutus.ChainIndex.ChainIndexError

Methods

parseJSON :: Value -> Parser RollbackFailed

parseJSONList :: Value -> Parser [RollbackFailed]

ToJSON RollbackFailed Source # 
Instance details

Defined in Plutus.ChainIndex.ChainIndexError

Methods

toJSON :: RollbackFailed -> Value

toEncoding :: RollbackFailed -> Encoding

toJSONList :: [RollbackFailed] -> Value

toEncodingList :: [RollbackFailed] -> Encoding

Pretty RollbackFailed Source # 
Instance details

Defined in Plutus.ChainIndex.ChainIndexError

Methods

pretty :: RollbackFailed -> Doc ann

prettyList :: [RollbackFailed] -> Doc ann

type Rep RollbackFailed Source # 
Instance details

Defined in Plutus.ChainIndex.ChainIndexError

type Rep RollbackFailed = D1 ('MetaData "RollbackFailed" "Plutus.ChainIndex.ChainIndexError" "plutus-chain-index-core-1.2.0.0-KXwe88sWnh3Kg9uXBYztrS" 'False) (C1 ('MetaCons "RollbackNoTip" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "TipMismatch" 'PrefixI 'True) (S1 ('MetaSel ('Just "foundTip") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Tip) :*: S1 ('MetaSel ('Just "targetPoint") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Point)) :+: C1 ('MetaCons "OldPointNotFound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Point))))

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 UtxoStates. 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 UtxoStates.