|
| 1 | +/* |
| 2 | +Copyright IBM Corp. All Rights Reserved. |
| 3 | +
|
| 4 | +SPDX-License-Identifier: Apache-2.0 |
| 5 | +*/ |
| 6 | + |
| 7 | +package statebased |
| 8 | + |
| 9 | +import ( |
| 10 | + "github.com/hyperledger/fabric/protos/peer" |
| 11 | +) |
| 12 | + |
| 13 | +// StateBasedValidator is used to validate a transaction that performs changes to |
| 14 | +// KVS keys that use key-level endorsement policies. This interface is supposed to be called |
| 15 | +// by any validator plugin (including the default validator plugin). The functions of this |
| 16 | +// interface are to be called as follows: |
| 17 | +// 1) the validator plugin extracts the read-write set from the transaction and calls PreValidate |
| 18 | +// (even before determining whether the transaction is valid) |
| 19 | +// 2) the validator plugin calls Validate before or after having determined the validity of the |
| 20 | +// transaction based on other considerations |
| 21 | +// 3) the validator plugin determines the overall validity of the transaction and then calls |
| 22 | +// PostValidate |
| 23 | +type StateBasedValidator interface { |
| 24 | + // PreValidate sets the internal data structures of the validator needed before validation |
| 25 | + // of `rwset` on the specified channel at the specified height |
| 26 | + PreValidate(ch, cc string, blockNum, txNum uint64, rwset []byte) error |
| 27 | + // TODO: remove the channel argument as part of FAB-9908 |
| 28 | + |
| 29 | + // Validate determines whether the transaction on the specified channel at the specified height |
| 30 | + // is valid according to its chaincode-level endorsement policy and any key-level validation |
| 31 | + // parametres |
| 32 | + Validate(ch, cc string, blockNum, txNum uint64, rwset, prp, ep []byte, endorsements []*peer.Endorsement) error |
| 33 | + // TODO: remove the channel argument as part of FAB-9908 |
| 34 | + |
| 35 | + // PostValidate sets the internal data structures of the validator needed after the validation |
| 36 | + // code was determined for a transaction on the specified channel at the specified height |
| 37 | + PostValidate(ch, cc string, blockNum, txNum uint64, vc peer.TxValidationCode) error |
| 38 | + // TODO: remove the channel argument as part of FAB-9908 |
| 39 | +} |
0 commit comments