github.com/IBM-Blockchain/fabric-operator@v1.0.4/pkg/initializer/orderer/configtx/config.go (about)

     1  /*
     2   * Copyright contributors to the Hyperledger Fabric Operator project
     3   *
     4   * SPDX-License-Identifier: Apache-2.0
     5   *
     6   * Licensed under the Apache License, Version 2.0 (the "License");
     7   * you may not use this file except in compliance with the License.
     8   * You may obtain a copy of the License at:
     9   *
    10   * 	  http://www.apache.org/licenses/LICENSE-2.0
    11   *
    12   * Unless required by applicable law or agreed to in writing, software
    13   * distributed under the License is distributed on an "AS IS" BASIS,
    14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    15   * See the License for the specific language governing permissions and
    16   * limitations under the License.
    17   */
    18  
    19  package configtx
    20  
    21  import (
    22  	"time"
    23  
    24  	"github.com/hyperledger/fabric-protos-go/orderer/etcdraft"
    25  )
    26  
    27  const (
    28  	// ConsensusTypeSolo identifies the solo consensus implementation.
    29  	ConsensusTypeSolo = "solo"
    30  	// ConsensusTypeKafka identifies the Kafka-based consensus implementation.
    31  	ConsensusTypeKafka = "kafka"
    32  	// ConsensusTypeKafka identifies the Kafka-based consensus implementation.
    33  	ConsensusTypeEtcdRaft = "etcdraft"
    34  
    35  	// BlockValidationPolicyKey
    36  	BlockValidationPolicyKey = "BlockValidation"
    37  
    38  	// OrdererAdminsPolicy is the absolute path to the orderer admins policy
    39  	OrdererAdminsPolicy = "/Channel/Orderer/Admins"
    40  
    41  	// SignaturePolicyType is the 'Type' string for signature policies
    42  	SignaturePolicyType = "Signature"
    43  
    44  	// ImplicitMetaPolicyType is the 'Type' string for implicit meta policies
    45  	ImplicitMetaPolicyType = "ImplicitMeta"
    46  
    47  	// AdminRoleAdminPrincipal is set as AdminRole to cause the MSP role of
    48  	// type Admin to be used as the admin principal default
    49  	AdminRoleAdminPrincipal = "Role.ADMIN"
    50  )
    51  
    52  // TopLevel consists of the structs used by the configtxgen tool.
    53  type TopLevel struct {
    54  	Profiles      map[string]*Profile        `yaml:"Profiles"`
    55  	Organizations []*Organization            `yaml:"Organizations"`
    56  	Channel       *Profile                   `yaml:"Channel"`
    57  	Application   *Application               `yaml:"Application"`
    58  	Orderer       *Orderer                   `yaml:"Orderer"`
    59  	Capabilities  map[string]map[string]bool `yaml:"Capabilities"`
    60  	Resources     *Resources                 `yaml:"Resources"`
    61  }
    62  
    63  // Profile encodes orderer/application configuration combinations for the
    64  // configtxgen tool.
    65  type Profile struct {
    66  	Consortium   string                 `yaml:"Consortium"`
    67  	Application  *Application           `yaml:"Application"`
    68  	Orderer      *Orderer               `yaml:"Orderer"`
    69  	Consortiums  map[string]*Consortium `yaml:"Consortiums"`
    70  	Capabilities map[string]bool        `yaml:"Capabilities"`
    71  	Policies     map[string]*Policy     `yaml:"Policies"`
    72  }
    73  
    74  // Policy encodes a channel config policy
    75  type Policy struct {
    76  	Type string `yaml:"Type"`
    77  	Rule string `yaml:"Rule"`
    78  }
    79  
    80  // Consortium represents a group of organizations which may create channels
    81  // with each other
    82  type Consortium struct {
    83  	Organizations []*Organization `yaml:"Organizations"`
    84  }
    85  
    86  // Application encodes the application-level configuration needed in config
    87  // transactions.
    88  type Application struct {
    89  	Organizations []*Organization    `yaml:"Organizations"`
    90  	Capabilities  map[string]bool    `yaml:"Capabilities"`
    91  	Resources     *Resources         `yaml:"Resources"`
    92  	Policies      map[string]*Policy `yaml:"Policies"`
    93  	ACLs          map[string]string  `yaml:"ACLs"`
    94  }
    95  
    96  // Resources encodes the application-level resources configuration needed to
    97  // seed the resource tree
    98  type Resources struct {
    99  	DefaultModPolicy string
   100  }
   101  
   102  // Organization encodes the organization-level configuration needed in
   103  // config transactions.
   104  type Organization struct {
   105  	Name     string             `yaml:"Name"`
   106  	ID       string             `yaml:"ID"`
   107  	MSPDir   string             `yaml:"MSPDir"`
   108  	MSPType  string             `yaml:"MSPType"`
   109  	Policies map[string]*Policy `yaml:"Policies"`
   110  
   111  	// Note: Viper deserialization does not seem to care for
   112  	// embedding of types, so we use one organization struct
   113  	// for both orderers and applications.
   114  	AnchorPeers      []*AnchorPeer `yaml:"AnchorPeers"`
   115  	OrdererEndpoints []string      `yaml:"OrdererEndpoints"`
   116  
   117  	// AdminPrincipal is deprecated and may be removed in a future release
   118  	// it was used for modifying the default policy generation, but policies
   119  	// may now be specified explicitly so it is redundant and unnecessary
   120  	AdminPrincipal string `yaml:"AdminPrincipal"`
   121  
   122  	// SkipAsForeign indicates that this org definition is actually unknown to this
   123  	// instance of the tool, so, parsing of this org's parameters should be ignored.
   124  	SkipAsForeign bool
   125  }
   126  
   127  // AnchorPeer encodes the necessary fields to identify an anchor peer.
   128  type AnchorPeer struct {
   129  	Host string `yaml:"Host"`
   130  	Port int    `yaml:"Port"`
   131  }
   132  
   133  // Orderer contains configuration associated to a channel.
   134  type Orderer struct {
   135  	OrdererType   string                   `yaml:"OrdererType"`
   136  	Addresses     []string                 `yaml:"Addresses"`
   137  	BatchTimeout  time.Duration            `yaml:"BatchTimeout"`
   138  	BatchSize     BatchSize                `yaml:"BatchSize"`
   139  	Kafka         Kafka                    `yaml:"Kafka"`
   140  	EtcdRaft      *etcdraft.ConfigMetadata `yaml:"EtcdRaft"`
   141  	Organizations []*Organization          `yaml:"Organizations"`
   142  	MaxChannels   uint64                   `yaml:"MaxChannels"`
   143  	Capabilities  map[string]bool          `yaml:"Capabilities"`
   144  	Policies      map[string]*Policy       `yaml:"Policies"`
   145  }
   146  
   147  // BatchSize contains configuration affecting the size of batches.
   148  type BatchSize struct {
   149  	MaxMessageCount   uint32 `yaml:"MaxMessageCount"`
   150  	AbsoluteMaxBytes  uint32 `yaml:"AbsoluteMaxBytes"`
   151  	PreferredMaxBytes uint32 `yaml:"PreferredMaxBytes"`
   152  }
   153  
   154  // Kafka contains configuration for the Kafka-based orderer.
   155  type Kafka struct {
   156  	Brokers []string `yaml:"Brokers"`
   157  }