Safe Haskell | None |
---|---|
Language | Haskell2010 |
Plutus.ChainIndex.UtxoState
Description
The UTXO state, kept in memory by the chain index.
Synopsis
- data UtxoState a = UtxoState {
- _usTxUtxoData :: a
- _usTip :: Tip
- usTxUtxoData :: forall a a. Lens (UtxoState a) (UtxoState a) a a
- usTip :: forall a. Lens' (UtxoState a) Tip
- type UtxoIndex a = FingerTree (BlockCount, UtxoState a) (UtxoState a)
- utxoState :: Monoid a => UtxoIndex a -> UtxoState a
- utxoBlockCount :: Monoid a => UtxoIndex a -> Int
- tip :: UtxoState a -> Tip
- viewTip :: Monoid a => UtxoIndex a -> Tip
- pointLessThanTip :: Point -> Tip -> Bool
- data InsertUtxoPosition
- data InsertUtxoSuccess a = InsertUtxoSuccess {}
- data InsertUtxoFailed
- insert :: (Monoid a, Eq a) => UtxoState a -> UtxoIndex a -> Either InsertUtxoFailed (InsertUtxoSuccess a)
- data RollbackFailed
- = RollbackNoTip
- | TipMismatch {
- foundTip :: Tip
- targetPoint :: Point
- | OldPointNotFound Point
- data RollbackResult a = RollbackResult {
- newTip :: Tip
- rolledBackIndex :: UtxoIndex a
- rollbackWith :: Monoid a => (UtxoIndex a -> UtxoIndex a -> UtxoIndex a) -> Point -> UtxoIndex a -> Either RollbackFailed (RollbackResult a)
- data ReduceBlockCountResult a
- reduceBlockCount :: Monoid a => Depth -> UtxoIndex a -> ReduceBlockCountResult a
- newtype BlockCount = BlockCount {
- getBlockCount :: Int
Documentation
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
usTxUtxoData :: forall a a. Lens (UtxoState a) (UtxoState a) a 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
data InsertUtxoSuccess a Source #
Constructors
InsertUtxoSuccess | |
Fields |
Instances
Pretty (InsertUtxoSuccess a) Source # | |
Defined in Plutus.ChainIndex.UtxoState |
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 |
Instances
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 |
Fields
| |
OldPointNotFound Point | Unable to find the old tip |
Instances
data RollbackResult a Source #
Constructors
RollbackResult | |
Fields
|
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
data ReduceBlockCountResult a Source #
Constructors
BlockCountNotReduced | |
ReduceBlockCountResult | |
Fields
|
reduceBlockCount :: Monoid a => Depth -> UtxoIndex a -> ReduceBlockCountResult a Source #
newtype BlockCount Source #
Constructors
BlockCount | |
Fields
|
Instances
Semigroup BlockCount Source # | |
Defined in Plutus.ChainIndex.UtxoState Methods (<>) :: BlockCount -> BlockCount -> BlockCount Source # sconcat :: NonEmpty BlockCount -> BlockCount Source # stimes :: Integral b => b -> BlockCount -> BlockCount Source # | |
Monoid BlockCount Source # | |
Defined in Plutus.ChainIndex.UtxoState Methods mempty :: BlockCount Source # mappend :: BlockCount -> BlockCount -> BlockCount Source # mconcat :: [BlockCount] -> BlockCount Source # | |
Monoid a => Measured (BlockCount, UtxoState a) (UtxoState a) Source # | |
Defined in Plutus.ChainIndex.UtxoState Methods measure :: UtxoState a -> (BlockCount, UtxoState a) |