This repository has been archived by the owner on Feb 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#526] Add TxValidationMode data type
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 () |