github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/core/handlers/validation/testdata/noop_validator.go (about)

     1  /*
     2  Copyright hechain. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package main
     8  
     9  import (
    10  	validation "github.com/hechain20/hechain/core/handlers/validation/api"
    11  	"github.com/hyperledger/fabric-protos-go/common"
    12  )
    13  
    14  // NoOpValidator is used to test validation plugin infrastructure
    15  type NoOpValidator struct {
    16  }
    17  
    18  // Validate valides the transactions with the given data
    19  func (*NoOpValidator) Validate(_ *common.Block, _ string, _ int, _ int, _ ...validation.ContextDatum) error {
    20  	return nil
    21  }
    22  
    23  // Init initializes the plugin with the given dependencies
    24  func (*NoOpValidator) Init(dependencies ...validation.Dependency) error {
    25  	return nil
    26  }
    27  
    28  // NoOpValidatorFactory creates new NoOpValidators
    29  type NoOpValidatorFactory struct {
    30  }
    31  
    32  // New returns an instance of a NoOpValidator
    33  func (*NoOpValidatorFactory) New() validation.Plugin {
    34  	return &NoOpValidator{}
    35  }
    36  
    37  // NewPluginFactory is called by the validation plugin framework to obtain an instance
    38  // of the factory
    39  func NewPluginFactory() validation.PluginFactory {
    40  	return &NoOpValidatorFactory{}
    41  }