github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/core/handlers/validation/builtin/v13/validator.go (about)

     1  /*
     2  Copyright hechain. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package v13
     8  
     9  import (
    10  	commonerrors "github.com/hechain20/hechain/common/errors"
    11  	"github.com/hyperledger/fabric-protos-go/common"
    12  	"github.com/hyperledger/fabric-protos-go/peer"
    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  }