Skip to content

Commit

Permalink
Remove Slot in favor of Read.SlotNo
Browse files Browse the repository at this point in the history
  • Loading branch information
HeinrichApfelmus committed Sep 12, 2024
1 parent 876db4b commit 9e91ac5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ genesis :: Read.ChainPoint
genesis = Read.Origin

getBlockPoint :: Read.Block -> Read.ChainPoint
getBlockPoint = Read.At . Read.slot . Read.blockHeaderBody . Read.blockHeader
getBlockPoint = Read.At . Read.slotNo . Read.blockHeaderBody . Read.blockHeader

mkNextBlock :: Read.ChainPoint -> [Tx Conway] -> Read.Block
mkNextBlock tipOld txs =
Expand All @@ -105,7 +105,7 @@ mkNextBlock tipOld txs =
{ Read.blockHeaderBody = Read.BHBody
{ Read.prev = Nothing
, Read.blockno = toEnum $ fromEnum slotNext
, Read.slot = slotNext
, Read.slotNo = slotNext
, Read.bhash = ()
}
, Read.blockHeaderSignature = ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ rollForwardUTxO isOurs block u =
UTxOHistory.appendBlock slot deltaUTxO u
where
(deltaUTxO,_) = Balance.applyBlock isOurs block (UTxOHistory.getUTxO u)
slot = Read.slot . Read.blockHeaderBody $ Read.blockHeader block
slot = Read.slotNo . Read.blockHeaderBody $ Read.blockHeader block

rollBackward
:: Read.ChainPoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ import qualified Data.Delta as Delta
Types
------------------------------------------------------------------------------}
type TxSubmissions
= Sbm.Submissions () Read.Slot (Read.TxId, Read.Tx)
= Sbm.Submissions () Read.SlotNo (Read.TxId, Read.Tx)
type TxSubmissionsStatus
= Sbm.TxStatusMeta () Read.Slot (Read.TxId, Read.Tx)
= Sbm.TxStatusMeta () Read.SlotNo (Read.TxId, Read.Tx)
type DeltaTxSubmissions1
= Sbm.Operation () Read.Slot (Read.TxId, Read.Tx)
= Sbm.Operation () Read.SlotNo (Read.TxId, Read.Tx)
type DeltaTxSubmissions
= [DeltaTxSubmissions1]

Expand All @@ -56,7 +56,7 @@ empty = Sbm.mkEmpty 0

-- | Add a /new/ transaction to the local submission pool
-- with the most recent submission slot.
add :: Read.Tx -> Read.Slot -> DeltaTxSubmissions
add :: Read.Tx -> Read.SlotNo -> DeltaTxSubmissions
add = undefined

listInSubmission :: TxSubmissions -> Set Read.Tx
Expand All @@ -69,5 +69,5 @@ rollForward block = [ Sbm.RollForward tip txs ]
txids = undefined block
txs = map (tip,) txids

rollBackward :: Read.Slot -> DeltaTxSubmissions
rollBackward :: Read.SlotNo -> DeltaTxSubmissions
rollBackward = undefined
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,10 @@ module Cardano.Wallet.Deposit.Pure.UTxOHistory
, getUTxO
) where

import Cardano.Wallet.Deposit.Pure.UTxO.DeltaUTxO
( DeltaUTxO
)
import Cardano.Wallet.Deposit.Pure.UTxO.UTxOHistory
( UTxOHistory
( DeltaUTxOHistory (..)
, UTxOHistory
, appendBlock
, empty
, getUTxO
)
import Cardano.Wallet.Deposit.Read
( Slot
, SlotNo
)

-- | Changes to the UTxO history.
data DeltaUTxOHistory
= -- | New slot tip, changes within that block.
AppendBlock SlotNo DeltaUTxO
| -- | Rollback tip.
Rollback Slot
| -- | Move finality forward.
Prune SlotNo
16 changes: 3 additions & 13 deletions lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/Read.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
-- TODO: Match this up with the @Read@ hierarchy.
module Cardano.Wallet.Deposit.Read
( Network (..)
, Slot
, Read.SlotNo
, toSlot
, fromSlot
Expand Down Expand Up @@ -79,18 +78,9 @@ import qualified Data.ByteString.Short as SBS
------------------------------------------------------------------------------}
data Network = Testnet | Mainnet

-- Spec: type Slot = Natural
type Slot = Read.SlotNo

toSlot :: Natural -> Slot
toSlot = Read.SlotNo

fromSlot :: Slot -> Natural
fromSlot (Read.SlotNo sl) = sl

data ChainPoint
= Origin
| At Slot
| At Read.SlotNo
deriving (Eq, Ord, Show)

-- | Synonym for readability.
Expand Down Expand Up @@ -154,7 +144,7 @@ type Sig = ()
data BHBody = BHBody
{ prev :: Maybe HashHeader
, blockno :: BlockNo
, slot :: Slot
, slotNo :: Read.SlotNo
, bhash :: HashBBody
}
deriving (Eq, Ord, Show)
Expand All @@ -166,7 +156,7 @@ dummyBHBody :: BHBody
dummyBHBody = BHBody
{ prev = Nothing
, blockno = 128
, slot = Read.SlotNo 42
, slotNo = Read.SlotNo 42
, bhash = ()
}

Expand Down

0 comments on commit 9e91ac5

Please sign in to comment.