github.com/adnan-c/fabric_e2e_couchdb@v0.6.1-preview.0.20170228180935-21ce6b23cf91/common/configtx/api/api.go (about) 1 /* 2 Copyright IBM Corp. 2017 All Rights Reserved. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package api 18 19 import ( 20 configvalues "github.com/hyperledger/fabric/common/configvalues" 21 configvalueschannel "github.com/hyperledger/fabric/common/configvalues/channel" 22 "github.com/hyperledger/fabric/common/policies" 23 "github.com/hyperledger/fabric/msp" 24 cb "github.com/hyperledger/fabric/protos/common" 25 ) 26 27 // Manager provides a mechanism to query and update config 28 type Manager interface { 29 Resources 30 31 // Apply attempts to apply a configtx to become the new config 32 Apply(configEnv *cb.ConfigEnvelope) error 33 34 // Validate attempts to apply a configtx to become the new config 35 Validate(configEnv *cb.ConfigEnvelope) error 36 37 // Validate attempts to validate a new configtx against the current config state 38 ProposeConfigUpdate(configtx *cb.Envelope) (*cb.ConfigEnvelope, error) 39 40 // ConfigEnvelope returns the *cb.ConfigEnvelope from the last successful Apply 41 ConfigEnvelope() *cb.ConfigEnvelope 42 43 // ChainID retrieves the chain ID associated with this manager 44 ChainID() string 45 46 // Sequence returns the current sequence number of the config 47 Sequence() uint64 48 } 49 50 // Resources is the common set of config resources for all channels 51 // Depending on whether chain is used at the orderer or at the peer, other 52 // config resources may be available 53 type Resources interface { 54 // PolicyManager returns the policies.Manager for the channel 55 PolicyManager() policies.Manager 56 57 // ChannelConfig returns the ChannelConfig for the chain 58 ChannelConfig() configvalueschannel.ConfigReader 59 60 // OrdererConfig returns the configtxorderer.SharedConfig for the channel 61 OrdererConfig() configvalues.Orderer 62 63 // ApplicationConfig returns the configtxapplication.SharedConfig for the channel 64 ApplicationConfig() configvalues.Application 65 66 // MSPManager returns the msp.MSPManager for the chain 67 MSPManager() msp.MSPManager 68 } 69 70 // Transactional is an interface which allows for an update to be proposed and rolled back 71 type Transactional interface { 72 // RollbackConfig called when a config proposal is abandoned 73 RollbackProposals() 74 75 // PreCommit verifies that the transaction can be committed successfully 76 PreCommit() error 77 78 // CommitConfig called when a config proposal is committed 79 CommitProposals() 80 } 81 82 // PolicyHandler is used for config updates to policy 83 type PolicyHandler interface { 84 Transactional 85 86 BeginConfig(groups []string) ([]PolicyHandler, error) 87 88 ProposePolicy(key string, path []string, policy *cb.ConfigPolicy) error 89 } 90 91 // Initializer is used as indirection between Manager and Handler to allow 92 // for single Handlers to handle multiple paths 93 type Initializer interface { 94 // ValueProposer return the root value proposer 95 ValueProposer() configvalues.ValueProposer 96 97 // PolicyProposer return the root policy proposer 98 PolicyProposer() policies.Proposer 99 100 Resources 101 }