github.com/yacovm/fabric@v2.0.0-alpha.0.20191128145320-c5d4087dc723+incompatible/common/capabilities/orderer.go (about) 1 /* 2 Copyright IBM Corp. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package capabilities 8 9 import ( 10 cb "github.com/hyperledger/fabric-protos-go/common" 11 ) 12 13 const ( 14 ordererTypeName = "Orderer" 15 16 // OrdererV1_1 is the capabilities string for standard new non-backwards compatible Fabric v1.1 orderer capabilities. 17 OrdererV1_1 = "V1_1" 18 19 // OrdererV1_4_2 is the capabilities string for standard new non-backwards compatible Fabric v1.4.2 orderer capabilities. 20 OrdererV1_4_2 = "V1_4_2" 21 22 // OrdererV2_0 is the capabilities string that defines new Fabric v2.0 orderer capabilities. 23 OrdererV2_0 = "V2_0" 24 ) 25 26 // OrdererProvider provides capabilities information for orderer level config. 27 type OrdererProvider struct { 28 *registry 29 v11BugFixes bool 30 v142 bool 31 V20 bool 32 } 33 34 // NewOrdererProvider creates an orderer capabilities provider. 35 func NewOrdererProvider(capabilities map[string]*cb.Capability) *OrdererProvider { 36 cp := &OrdererProvider{} 37 cp.registry = newRegistry(cp, capabilities) 38 _, cp.v11BugFixes = capabilities[OrdererV1_1] 39 _, cp.v142 = capabilities[OrdererV1_4_2] 40 _, cp.V20 = capabilities[OrdererV2_0] 41 return cp 42 } 43 44 // Type returns a descriptive string for logging purposes. 45 func (cp *OrdererProvider) Type() string { 46 return ordererTypeName 47 } 48 49 // HasCapability returns true if the capability is supported by this binary. 50 func (cp *OrdererProvider) HasCapability(capability string) bool { 51 switch capability { 52 // Add new capability names here 53 case OrdererV1_1: 54 return true 55 case OrdererV1_4_2: 56 return true 57 case OrdererV2_0: 58 return true 59 default: 60 return false 61 } 62 } 63 64 // PredictableChannelTemplate specifies whether the v1.0 undesirable behavior of setting the /Channel 65 // group's mod_policy to "" and copying versions from the channel config should be fixed or not. 66 func (cp *OrdererProvider) PredictableChannelTemplate() bool { 67 return cp.v11BugFixes || cp.v142 || cp.V20 68 } 69 70 // Resubmission specifies whether the v1.0 non-deterministic commitment of tx should be fixed by re-submitting 71 // the re-validated tx. 72 func (cp *OrdererProvider) Resubmission() bool { 73 return cp.v11BugFixes || cp.v142 || cp.V20 74 } 75 76 // ExpirationCheck specifies whether the orderer checks for identity expiration checks 77 // when validating messages 78 func (cp *OrdererProvider) ExpirationCheck() bool { 79 return cp.v11BugFixes || cp.v142 || cp.V20 80 } 81 82 // ConsensusTypeMigration checks whether the orderer permits a consensus-type migration. 83 // 84 // A Kafka-based Ordering Service Node requires these capabilities in order to receive and process a config update 85 // with consensus-type migration change. Migration is supported from Kafka to Raft only. 86 // If not present, these config updates will be rejected. 87 func (cp *OrdererProvider) ConsensusTypeMigration() bool { 88 return cp.v142 || cp.V20 89 } 90 91 // UseChannelCreationPolicyAsAdmins determines whether the orderer should use the name 92 // "Admins" instead of "ChannelCreationPolicy" in the new channel config template. 93 func (cp *OrdererProvider) UseChannelCreationPolicyAsAdmins() bool { 94 return cp.V20 95 }