Skip to content

Commit

Permalink
Add UTxOHistory datatype as internal module.
Browse files Browse the repository at this point in the history
  • Loading branch information
paolino committed Mar 16, 2023
1 parent 8e55c9e commit e8a62ca
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/wallet/cardano-wallet.cabal
Expand Up @@ -236,6 +236,7 @@ library
Cardano.Wallet.DB.Sqlite.Stores
Cardano.Wallet.DB.Sqlite.Types
Cardano.Wallet.DB.Store.Checkpoints
Cardano.Wallet.DB.Store.DeltaUTxO.Model.Internal
Cardano.Wallet.DB.Store.Meta.Model
Cardano.Wallet.DB.Store.Meta.Store
Cardano.Wallet.DB.Store.QueryStore
Expand Down
36 changes: 36 additions & 0 deletions lib/wallet/src/Cardano/Wallet/DB/Store/DeltaUTxO/Model/Internal.hs
@@ -0,0 +1,36 @@
module Cardano.Wallet.DB.Store.DeltaUTxO.Model.Internal
( UTxOHistory (..)
)
where

import Prelude

import Cardano.Wallet.Primitive.Types
( Slot, SlotNo )
import Cardano.Wallet.Primitive.Types.Tx.TxIn
( TxIn )
import Cardano.Wallet.Primitive.Types.UTxO
( UTxO )
import Data.Map.Strict
( Map )
import Data.Set
( Set )

-- | UTxO history. Abstract history of the UTxO. We keep track of the creation
-- and spending of slot of each TxIn. This allows us to rollback to a given slot
-- and prune the history to a given slot.
data UTxOHistory = UTxOHistory
{ history :: UTxO
-- ^ All UTxO , spent and unspent.
, creationSlots :: Map Slot (Set TxIn)
-- ^ All TxIn, indexed by creation slot.
, spentSlots :: Map SlotNo (Set TxIn)
-- ^ All spent TxIn, indexed by spent slot.
, spentTxIns :: Map TxIn SlotNo
-- ^ All spent TxIn.
, tip :: Slot
-- ^ Current tip slot.
, finality :: Maybe Slot
-- ^ Finality slot.
}
deriving (Show)

0 comments on commit e8a62ca

Please sign in to comment.