From 3c6f96db302819491bb6583e4e6fd50b5d691096 Mon Sep 17 00:00:00 2001 From: Rodney Lorrimar Date: Wed, 5 Aug 2020 16:48:49 +1000 Subject: [PATCH] Add pending tx expiry to TxMeta --- lib/core/src/Cardano/Wallet.hs | 1 + lib/core/src/Cardano/Wallet/Primitive/Model.hs | 1 + lib/core/src/Cardano/Wallet/Primitive/Types.hs | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/core/src/Cardano/Wallet.hs b/lib/core/src/Cardano/Wallet.hs index 886bc089f4f..f0c82ea2b4b 100644 --- a/lib/core/src/Cardano/Wallet.hs +++ b/lib/core/src/Cardano/Wallet.hs @@ -1726,6 +1726,7 @@ mkTxMeta interpretTime blockHeader wState cs = , slotNo = blockHeader ^. #slotNo , blockHeight = blockHeader ^. #blockHeight , amount = Quantity (amtInps - amtOuts) + , expiry = Just (error "fixme: expiry slot") } ) where diff --git a/lib/core/src/Cardano/Wallet/Primitive/Model.hs b/lib/core/src/Cardano/Wallet/Primitive/Model.hs index 45baec33e90..2d0165dfd24 100644 --- a/lib/core/src/Cardano/Wallet/Primitive/Model.hs +++ b/lib/core/src/Cardano/Wallet/Primitive/Model.hs @@ -372,6 +372,7 @@ prefilterBlock b u0 = runState $ do , slotNo = b ^. #header . #slotNo , blockHeight = b ^. #header . #blockHeight , amount = Quantity amt + , expiry = Nothing } applyTx :: (IsOurs s Address) diff --git a/lib/core/src/Cardano/Wallet/Primitive/Types.hs b/lib/core/src/Cardano/Wallet/Primitive/Types.hs index 1dcfe31651e..cf2a79f76a6 100644 --- a/lib/core/src/Cardano/Wallet/Primitive/Types.hs +++ b/lib/core/src/Cardano/Wallet/Primitive/Types.hs @@ -879,15 +879,17 @@ data TxMeta = TxMeta , slotNo :: !SlotNo , blockHeight :: !(Quantity "block" Word32) , amount :: !(Quantity "lovelace" Natural) + , expiry :: !(Maybe SlotNo) } deriving (Show, Eq, Ord, Generic) instance NFData TxMeta instance Buildable TxMeta where - build (TxMeta s d sl (Quantity bh) (Quantity a)) = mempty + build (TxMeta s d sl (Quantity bh) (Quantity a) mex) = mempty <> (case d of; Incoming -> "+"; Outgoing -> "-") <> fixedF @Double 6 (fromIntegral a / 1e6) <> " " <> build s + <> maybe mempty (\ex -> " expires " <> build ex) mex <> " since " <> build sl <> "#" <> build bh data TxStatus