Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
rvl committed Jul 9, 2020
1 parent 9c44a04 commit 19d373c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions lib/core/src/Cardano/Wallet/DB/Sqlite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ newDBLayer trace defaultFieldValues mDatabaseFile = do
deleteDelegationCertificates wid
[ CertSlot >. nearestPoint
]
-- fixme: transfer outgoing TxMeta back to TxPending
updateTxMetas wid
[ TxMetaDirection ==. W.Outgoing
, TxMetaSlot >. nearestPoint
Expand Down
22 changes: 14 additions & 8 deletions lib/core/src/Cardano/Wallet/DB/Sqlite/TH.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,28 @@ PrivateKey sql=private_key
TxMeta
txMetaTxId TxId sql=tx_id
txMetaWalletId W.WalletId sql=wallet_id
txMetaStatus W.TxStatus sql=status
txMetaDirection W.Direction sql=direction
txMetaSlot W.SlotId sql=slot
txMetaBlockHeight Word32 sql=block_height
txMetaAmount Natural sql=amount
txMetaExpiry W.SlotId sql=expiry

-- probably worth splitting TxPending off from TxMeta
-- because they are sufficiently different
-- in both form and behaviour.

Primary txMetaTxId txMetaWalletId
Foreign Wallet fk_wallet_tx_meta txMetaWalletId ! ON DELETE CASCADE
deriving Show Generic

-- A transaction input associated with TxMeta.
-- Metadata for a transaction which has been submitted but has
-- not yet appeared in the ledger.
TxPending
txPendingTxId TxId sql=tx_id
txPendingWalletId W.WalletId sql=wallet_id
txPendingAmount Natural sql=amount
txPendingExpiry W.SlotId sql=expiry

Primary txPendingTxId txPendingWalletId
Foreign Wallet fk_wallet_pending_tx txPendingWalletId ! ON DELETE CASCADE
deriving Show Generic

-- A transaction input associated with TxMeta or TxPending.
--
-- There is no wallet ID because these values depend only on the transaction,
-- not the wallet. txInputTxId is referred to by TxMeta
Expand All @@ -117,7 +123,7 @@ TxIn
Primary txInputTxId txInputSourceTxId txInputSourceIndex
deriving Show Generic

-- A transaction output associated with TxMeta.
-- A transaction output associated with TxMeta or TxPending.
--
-- There is no wallet ID because these values depend only on the transaction,
-- not the wallet. txOutputTxId is referred to by TxMeta
Expand Down
3 changes: 3 additions & 0 deletions lib/core/src/Cardano/Wallet/Primitive/Model.hs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ applyBlocks (block0 :| blocks) cp =
-------------------------------------------------------------------------------}

-- | Available balance = 'balance' . 'availableUTxO'
--
-- fixme: not sure whether to "infect" this module with PendingTx.
-- Maybe better to extract 'pendingTx' before calling these functions.
availableBalance :: Set PendingTx -> Wallet s -> Natural
availableBalance pending =
balance . availableUTxO pending
Expand Down
1 change: 1 addition & 0 deletions lib/core/src/Cardano/Wallet/Primitive/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,7 @@ data PendingTx = PendingTx
-- ^ The transaction.
, expiry :: !SlotId
-- ^ The future slot at which the transaction will expire.
-- TTL is supported by the shelley ledger. For others, we can pretend.
}
deriving (Generic, Eq, Show)

Expand Down

0 comments on commit 19d373c

Please sign in to comment.