github.com/kaituanwang/hyperledger@v2.0.1+incompatible/core/committer/txvalidator/plugin/plugin.go (about) 1 /* 2 Copyright IBM Corp. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package plugin 8 9 import validation "github.com/hyperledger/fabric/core/handlers/validation/api" 10 11 // Name defines the name of the plugin as it appears in the configuration 12 type Name string 13 14 // Mapper maps plugin names to their corresponding factory instance. 15 // Returns nil if the name isn't associated to any plugin. 16 type Mapper interface { 17 FactoryByName(name Name) validation.PluginFactory 18 } 19 20 // MapBasedMapper maps plugin names to their corresponding factories 21 type MapBasedMapper map[string]validation.PluginFactory 22 23 // FactoryByName returns a plugin factory for the given plugin name, or nil if not found 24 func (m MapBasedMapper) FactoryByName(name Name) validation.PluginFactory { 25 return m[string(name)] 26 } 27 28 // SerializedPolicy defines a marshaled policy 29 type SerializedPolicy []byte 30 31 // Bytes returns te bytes of the SerializedPolicy 32 func (sp SerializedPolicy) Bytes() []byte { 33 return sp 34 }