github.com/myafeier/fabric@v1.0.1-0.20170722181825-3a4b1f2bce86/common/config/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  // Note, the directory is still configvalues, but this is stuttery and config
    18  // is a more accurate and better name, TODO, update directory
    19  package config
    20  
    21  import (
    22  	"time"
    23  
    24  	cb "github.com/hyperledger/fabric/protos/common"
    25  	ab "github.com/hyperledger/fabric/protos/orderer"
    26  	pb "github.com/hyperledger/fabric/protos/peer"
    27  )
    28  
    29  // Org stores the common organizational config
    30  type Org interface {
    31  	// Name returns the name this org is referred to in config
    32  	Name() string
    33  
    34  	// MSPID returns the MSP ID associated with this org
    35  	MSPID() string
    36  }
    37  
    38  // ApplicationOrg stores the per org application config
    39  type ApplicationOrg interface {
    40  	Org
    41  
    42  	// AnchorPeers returns the list of gossip anchor peers
    43  	AnchorPeers() []*pb.AnchorPeer
    44  }
    45  
    46  // Application stores the common shared application config
    47  type Application interface {
    48  	// Organizations returns a map of org ID to ApplicationOrg
    49  	Organizations() map[string]ApplicationOrg
    50  }
    51  
    52  // Channel gives read only access to the channel configuration
    53  type Channel interface {
    54  	// HashingAlgorithm returns the default algorithm to be used when hashing
    55  	// such as computing block hashes, and CreationPolicy digests
    56  	HashingAlgorithm() func(input []byte) []byte
    57  
    58  	// BlockDataHashingStructureWidth returns the width to use when constructing the
    59  	// Merkle tree to compute the BlockData hash
    60  	BlockDataHashingStructureWidth() uint32
    61  
    62  	// OrdererAddresses returns the list of valid orderer addresses to connect to to invoke Broadcast/Deliver
    63  	OrdererAddresses() []string
    64  }
    65  
    66  // Consortiums represents the set of consortiums serviced by an ordering service
    67  type Consortiums interface {
    68  	// Consortiums returns the set of consortiums
    69  	Consortiums() map[string]Consortium
    70  }
    71  
    72  // Consortium represents a group of orgs which may create channels together
    73  type Consortium interface {
    74  	// ChannelCreationPolicy returns the policy to check when instantiating a channel for this consortium
    75  	ChannelCreationPolicy() *cb.Policy
    76  }
    77  
    78  // Orderer stores the common shared orderer config
    79  type Orderer interface {
    80  	// ConsensusType returns the configured consensus type
    81  	ConsensusType() string
    82  
    83  	// BatchSize returns the maximum number of messages to include in a block
    84  	BatchSize() *ab.BatchSize
    85  
    86  	// BatchTimeout returns the amount of time to wait before creating a batch
    87  	BatchTimeout() time.Duration
    88  
    89  	// MaxChannelsCount returns the maximum count of channels to allow for an ordering network
    90  	MaxChannelsCount() uint64
    91  
    92  	// KafkaBrokers returns the addresses (IP:port notation) of a set of "bootstrap"
    93  	// Kafka brokers, i.e. this is not necessarily the entire set of Kafka brokers
    94  	// used for ordering
    95  	KafkaBrokers() []string
    96  
    97  	// Organizations returns the organizations for the ordering service
    98  	Organizations() map[string]Org
    99  }
   100  
   101  type ValueProposer interface {
   102  	// BeginValueProposals called when a config proposal is begun
   103  	BeginValueProposals(tx interface{}, groups []string) (ValueDeserializer, []ValueProposer, error)
   104  
   105  	// RollbackProposals called when a config proposal is abandoned
   106  	RollbackProposals(tx interface{})
   107  
   108  	// PreCommit is invoked before committing the config to catch
   109  	// any errors which cannot be caught on a per proposal basis
   110  	// TODO, rename other methods to remove Value/Proposal references
   111  	PreCommit(tx interface{}) error
   112  
   113  	// CommitProposals called when a config proposal is committed
   114  	CommitProposals(tx interface{})
   115  }