github.com/anjalikarhana/fabric@v2.1.1+incompatible/integration/nwo/standard_networks.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package nwo
     8  
     9  // BasicSolo is a configuration wtih two organizations and one peer per org.
    10  func BasicSolo() *Config {
    11  	return &Config{
    12  		Organizations: []*Organization{{
    13  			Name:          "OrdererOrg",
    14  			MSPID:         "OrdererMSP",
    15  			Domain:        "example.com",
    16  			EnableNodeOUs: false,
    17  			Users:         0,
    18  			CA:            &CA{Hostname: "ca"},
    19  		}, {
    20  			Name:          "Org1",
    21  			MSPID:         "Org1MSP",
    22  			Domain:        "org1.example.com",
    23  			EnableNodeOUs: true,
    24  			Users:         2,
    25  			CA:            &CA{Hostname: "ca"},
    26  		}, {
    27  			Name:          "Org2",
    28  			MSPID:         "Org2MSP",
    29  			Domain:        "org2.example.com",
    30  			EnableNodeOUs: true,
    31  			Users:         2,
    32  			CA:            &CA{Hostname: "ca"},
    33  		}},
    34  		Consortiums: []*Consortium{{
    35  			Name: "SampleConsortium",
    36  			Organizations: []string{
    37  				"Org1",
    38  				"Org2",
    39  			},
    40  		}},
    41  		Consensus: &Consensus{
    42  			Type: "solo",
    43  		},
    44  		SystemChannel: &SystemChannel{
    45  			Name:    "systemchannel",
    46  			Profile: "TwoOrgsOrdererGenesis",
    47  		},
    48  		Orderers: []*Orderer{
    49  			{Name: "orderer", Organization: "OrdererOrg"},
    50  		},
    51  		Channels: []*Channel{
    52  			{Name: "testchannel", Profile: "TwoOrgsChannel"},
    53  		},
    54  		Peers: []*Peer{{
    55  			Name:         "peer0",
    56  			Organization: "Org1",
    57  			Channels: []*PeerChannel{
    58  				{Name: "testchannel", Anchor: true},
    59  			},
    60  		}, {
    61  			Name:         "peer0",
    62  			Organization: "Org2",
    63  			Channels: []*PeerChannel{
    64  				{Name: "testchannel", Anchor: true},
    65  			},
    66  		}},
    67  		Profiles: []*Profile{{
    68  			Name:     "TwoOrgsOrdererGenesis",
    69  			Orderers: []string{"orderer"},
    70  		}, {
    71  			Name:          "TwoOrgsChannel",
    72  			Consortium:    "SampleConsortium",
    73  			Organizations: []string{"Org1", "Org2"},
    74  		}},
    75  	}
    76  }
    77  
    78  // FullSolo is a configuration wtih two organizations and two peers per org.
    79  func FullSolo() *Config {
    80  	config := BasicSolo()
    81  
    82  	config.Peers = append(
    83  		config.Peers,
    84  		&Peer{
    85  			Name:         "peer1",
    86  			Organization: "Org1",
    87  			Channels: []*PeerChannel{
    88  				{Name: "testchannel", Anchor: false},
    89  			},
    90  		},
    91  		&Peer{
    92  			Name:         "peer1",
    93  			Organization: "Org2",
    94  			Channels: []*PeerChannel{
    95  				{Name: "testchannel", Anchor: false},
    96  			},
    97  		},
    98  	)
    99  
   100  	return config
   101  }
   102  
   103  func BasicSoloWithIdemix() *Config {
   104  	config := BasicSolo()
   105  
   106  	// Add idemix organization
   107  	config.Organizations = append(config.Organizations, &Organization{
   108  		Name:          "Org3",
   109  		MSPID:         "Org3MSP",
   110  		MSPType:       "idemix",
   111  		Domain:        "org3.example.com",
   112  		EnableNodeOUs: false,
   113  		Users:         0,
   114  		CA:            &CA{Hostname: "ca"},
   115  	})
   116  	// Add idemix organization to consortium
   117  	config.Consortiums[0].Organizations = append(config.Consortiums[0].Organizations, "Org3")
   118  	config.Profiles[1].Organizations = append(config.Profiles[1].Organizations, "Org3")
   119  
   120  	return config
   121  }
   122  
   123  func MultiChannelBasicSolo() *Config {
   124  	config := BasicSolo()
   125  
   126  	config.Channels = []*Channel{
   127  		{Name: "testchannel", Profile: "TwoOrgsChannel"},
   128  		{Name: "testchannel2", Profile: "TwoOrgsChannel"},
   129  	}
   130  
   131  	for _, peer := range config.Peers {
   132  		peer.Channels = []*PeerChannel{
   133  			{Name: "testchannel", Anchor: true},
   134  			{Name: "testchannel2", Anchor: true},
   135  		}
   136  	}
   137  
   138  	return config
   139  }
   140  
   141  func BasicKafka() *Config {
   142  	config := BasicSolo()
   143  
   144  	config.Consensus.Type = "kafka"
   145  	config.Consensus.ZooKeepers = 1
   146  	config.Consensus.Brokers = 1
   147  
   148  	return config
   149  }
   150  
   151  func BasicEtcdRaft() *Config {
   152  	config := BasicSolo()
   153  
   154  	config.Consensus.Type = "etcdraft"
   155  	config.Profiles = []*Profile{{
   156  		Name:     "SampleDevModeEtcdRaft",
   157  		Orderers: []string{"orderer"},
   158  	}, {
   159  		Name:          "TwoOrgsChannel",
   160  		Consortium:    "SampleConsortium",
   161  		Organizations: []string{"Org1", "Org2"},
   162  	}}
   163  	config.SystemChannel.Profile = "SampleDevModeEtcdRaft"
   164  
   165  	return config
   166  }
   167  
   168  func MinimalRaft() *Config {
   169  	config := BasicEtcdRaft()
   170  
   171  	config.Peers[1].Channels = nil
   172  	config.Channels = []*Channel{
   173  		{Name: "testchannel", Profile: "OneOrgChannel"},
   174  	}
   175  	config.Profiles = []*Profile{{
   176  		Name:     "SampleDevModeEtcdRaft",
   177  		Orderers: []string{"orderer"},
   178  	}, {
   179  		Name:          "OneOrgChannel",
   180  		Consortium:    "SampleConsortium",
   181  		Organizations: []string{"Org1"},
   182  	}}
   183  
   184  	return config
   185  }
   186  
   187  func MultiChannelEtcdRaft() *Config {
   188  	config := MultiChannelBasicSolo()
   189  
   190  	config.Consensus.Type = "etcdraft"
   191  	config.Profiles = []*Profile{{
   192  		Name:     "SampleDevModeEtcdRaft",
   193  		Orderers: []string{"orderer"},
   194  	}, {
   195  		Name:          "TwoOrgsChannel",
   196  		Consortium:    "SampleConsortium",
   197  		Organizations: []string{"Org1", "Org2"},
   198  	}}
   199  	config.SystemChannel.Profile = "SampleDevModeEtcdRaft"
   200  
   201  	return config
   202  }
   203  
   204  func MultiNodeEtcdRaft() *Config {
   205  	config := BasicEtcdRaft()
   206  	config.Orderers = []*Orderer{
   207  		{Name: "orderer1", Organization: "OrdererOrg"},
   208  		{Name: "orderer2", Organization: "OrdererOrg"},
   209  		{Name: "orderer3", Organization: "OrdererOrg"},
   210  	}
   211  	config.Profiles = []*Profile{{
   212  		Name:     "SampleDevModeEtcdRaft",
   213  		Orderers: []string{"orderer1", "orderer2", "orderer3"},
   214  	}, {
   215  		Name:          "TwoOrgsChannel",
   216  		Consortium:    "SampleConsortium",
   217  		Organizations: []string{"Org1", "Org2"},
   218  	}}
   219  	return config
   220  }