Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
[#526] Add TxValidationMode data type
Browse files Browse the repository at this point in the history
  • Loading branch information
intricate committed Jun 18, 2019
1 parent 1a60e40 commit 851a93a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions cardano-ledger/cardano-ledger.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ library
Cardano.Chain.UTxO.UTxOConfiguration
Cardano.Chain.UTxO.TxProof
Cardano.Chain.UTxO.TxWitness
Cardano.Chain.UTxO.ValidationMode

Cardano.Chain.Update.ApplicationName
Cardano.Chain.Update.InstallerHash
Expand Down
34 changes: 34 additions & 0 deletions cardano-ledger/src/Cardano/Chain/UTxO/ValidationMode.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module Cardano.Chain.UTxO.ValidationMode
( TxValidationMode (..)
, whenTxValidation
) where

import Cardano.Prelude

--------------------------------------------------------------------------------
-- TxValidationMode
--------------------------------------------------------------------------------

-- | Indicates what sort of transaction validation should be performed.
data TxValidationMode
= TxValidation
-- ^ Perform all transaction validations.
| TxValidationNoCrypto
-- ^ Because we've already validated this tranaction against some ledger
-- state, we know that cryptographic validation has passed. However, we
-- should still perform all of the other non-cryptographic checks since
-- we're validating against a potentially dfferent ledger state.
| NoTxValidation
-- ^ No validations should be performed as we have already validated this
-- transaction against this very same ledger state.
deriving (Eq, Show)

-- | Perform an action only when in the 'TxValidation' mode. Otherwise, do
-- nothing.
whenTxValidation
:: MonadError err m
=> TxValidationMode
-> m ()
-> m ()
whenTxValidation TxValidation action = action
whenTxValidation _ _ = pure ()

0 comments on commit 851a93a

Please sign in to comment.