github.com/lzy4123/fabric@v2.1.1+incompatible/core/handlers/validation/builtin/v20/validator.go (about) 1 /* 2 Copyright IBM Corp. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package v20 8 9 import ( 10 "github.com/hyperledger/fabric-protos-go/common" 11 "github.com/hyperledger/fabric-protos-go/peer" 12 commonerrors "github.com/hyperledger/fabric/common/errors" 13 ) 14 15 // StateBasedValidator is used to validate a transaction that performs changes to 16 // KVS keys that use key-level endorsement policies. This interface is supposed to be called 17 // by any validator plugin (including the default validator plugin). The functions of this 18 // interface are to be called as follows: 19 // 1) the validator plugin calls PreValidate (even before determining whether the transaction is 20 // valid) 21 // 2) the validator plugin calls Validate before or after having determined the validity of the 22 // transaction based on other considerations 23 // 3) the validator plugin determines the overall validity of the transaction and then calls 24 // PostValidate 25 type StateBasedValidator interface { 26 // PreValidate sets the internal data structures of the validator needed before validation 27 // of transaction `txNum` in the specified block can proceed 28 PreValidate(txNum uint64, block *common.Block) 29 30 // Validate determines whether the transaction on the specified channel at the specified height 31 // is valid according to its chaincode-level endorsement policy and any key-level validation 32 // parametres 33 Validate(cc string, blockNum, txNum uint64, rwset, prp, ep []byte, endorsements []*peer.Endorsement) commonerrors.TxValidationError 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(cc string, blockNum, txNum uint64, err error) 38 }