nwo

package
v1.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2019 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultConfigTxTemplate = `` /* 3631-byte string literal not displayed */
View Source
const DefaultCoreTemplate = `` /* 5184-byte string literal not displayed */
View Source
const DefaultCryptoTemplate = `` /* 845-byte string literal not displayed */
View Source
const DefaultOrdererTemplate = `` /* 3063-byte string literal not displayed */

Variables

View Source
var RequiredImages = []string{
	fmt.Sprintf("hyperledger/fabric-ccenv:%s-latest", runtime.GOARCH),
	runner.CouchDBDefaultImage,
	runner.KafkaDefaultImage,
	runner.ZooKeeperDefaultImage,
}

Functions

func AddConsenter

func AddConsenter(n *Network, peer *Peer, orderer *Orderer, channel string, consenter ectdraft_protos.Consenter)

AddConsenter adds a new consenter to the given channel

func ComputeUpdateOrdererConfig

func ComputeUpdateOrdererConfig(updateFile string, n *Network, channel string, current, updated *common.Config, submitter *Peer, additionalSigners ...*Orderer)

func ConnectsToOrderer

func ConnectsToOrderer(c Command) bool

func CurrentConfigBlockNumber

func CurrentConfigBlockNumber(n *Network, peer *Peer, orderer *Orderer, channel string) uint64

CurrentConfigBlockNumber retrieves the block number from the header of the current config block. This can be used to detect when configuration change has completed. If an orderer is not provided, the current config block will be fetched from the peer.

func CurrentConfigBlockNumberFromPeer

func CurrentConfigBlockNumberFromPeer(n *Network, peer *Peer, channel, output string) uint64

CurrentConfigBlockNumberFromPeer retrieves the block number from the header of the peer's current config block.

func DeployChaincode

func DeployChaincode(n *Network, channel string, orderer *Orderer, chaincode Chaincode, peers ...*Peer)

DeployChaincode is a helper that will install chaincode to all peers that are connected to the specified channel, instantiate the chaincode on one of the peers, and wait for the instantiation to complete on all of the peers.

NOTE: This helper should not be used to deploy the same chaincode on multiple channels as the install will fail on subsequent calls. Instead, simply use InstantiateChaincode().

func DiscoverPeers

func DiscoverPeers(n *Network, p *Peer, user, channelName string) func() []DiscoveredPeer

running discovery service command discover peers against peer using channel name and user as specified in the function arguments. return a slice of the discovered peers

func EnableCapabilities

func EnableCapabilities(network *Network, channel, capabilitiesGroup, capabilitiesVersion string, orderer *Orderer, peers ...*Peer)

EnableCapabilities enables a specific capabilities flag for a running network. It generates the config update using the first peer, signs the configuration with the subsequent peers, and then submits the config update using the first peer.

func EnableCapabilitiesOrdererAdmin

func EnableCapabilitiesOrdererAdmin(network *Network, channel, capabilitiesGroup, capabilitiesVersion string, orderer *Orderer, peer *Peer, additionalSigners ...*Orderer)

EnableCapabilitiesOrdererAdmin enables a specific capabilities flag for a running network, using an Orderer Admin Session. This is required to make changes on the system channel, for example.

func EnsureInstantiated

func EnsureInstantiated(n *Network, channel, name, version string, peers ...*Peer)

func FetchConfigBlock

func FetchConfigBlock(n *Network, peer *Peer, orderer *Orderer, channel string, output string)

FetchConfigBlock fetches latest config block.

func GetConfig

func GetConfig(n *Network, peer *Peer, orderer *Orderer, channel string) *common.Config

GetConfig retrieves the last config of the given channel

func GetConfigBlock

func GetConfigBlock(n *Network, peer *Peer, orderer *Orderer, channel string) *common.Block

GetConfigBlock retrieves the current config block for a channel

func InstallChaincode

func InstallChaincode(n *Network, chaincode Chaincode, peers ...*Peer)

func InstantiateChaincode

func InstantiateChaincode(n *Network, channel string, orderer *Orderer, chaincode Chaincode, peer *Peer, checkPeers ...*Peer)

func NewCommand

func NewCommand(path string, command Command) *exec.Cmd

func PackageChaincode

func PackageChaincode(n *Network, chaincode Chaincode, peer *Peer)

func RemoveConsenter

func RemoveConsenter(n *Network, peer *Peer, orderer *Orderer, channel string, certificate []byte)

RemoveConsenter removes a consenter with the given certificate in PEM format from the given channel

func UnmarshalBlockFromFile

func UnmarshalBlockFromFile(blockFile string) *common.Block

UnmarshalBlockFromFile unmarshals a proto encoded block from a file.

func UpdateConfig

func UpdateConfig(n *Network, orderer *Orderer, channel string, current, updated *common.Config, getConfigBlockFromOrderer bool, submitter *Peer, additionalSigners ...*Peer)

UpdateConfig computes, signs, and submits a configuration update and waits for the update to complete.

func UpdateConsensusMetadata

func UpdateConsensusMetadata(network *Network, peer *Peer, orderer *Orderer, channel string, mutateMetadata ConsensusMetadataMutator)

UpdateConsensusMetadata executes a config update that updates the consensus metadata according to the given ConsensusMetadataMutator

func UpdateEtcdRaftMetadata

func UpdateEtcdRaftMetadata(network *Network, peer *Peer, orderer *Orderer, channel string, f func(md *ectdraft_protos.ConfigMetadata))

UpdateEtcdRaftMetadata executes a config update that updates the etcdraft metadata according to the given function f

func UpdateOrdererConfig

func UpdateOrdererConfig(n *Network, orderer *Orderer, channel string, current, updated *common.Config, submitter *Peer, additionalSigners ...*Orderer)

UpdateOrdererConfig computes, signs, and submits a configuration update which requires orderers signature and waits for the update to complete.

func UpdateOrdererConfigFail

func UpdateOrdererConfigFail(n *Network, orderer *Orderer, channel string, current, updated *common.Config, submitter *Peer, additionalSigners ...*Orderer)

UpdateOrdererConfigFail computes, signs, and submits a configuration update which requires orderers signature and waits for the update to FAIL.

func UpgradeChaincode

func UpgradeChaincode(n *Network, channel string, orderer *Orderer, chaincode Chaincode, peers ...*Peer)

Types

type CA

type CA struct {
	Hostname string `yaml:"hostname,omitempty"`
}

type Chaincode

type Chaincode struct {
	Name              string
	Version           string
	Path              string
	Ctor              string
	Policy            string
	Lang              string
	CollectionsConfig string // optional
	PackageFile       string
}

type Channel

type Channel struct {
	Name        string `yaml:"name,omitempty"`
	Profile     string `yaml:"profile,omitempty"`
	BaseProfile string `yaml:"baseprofile,omitempty"`
}

Channel associates a channel name with a configtxgen profile name.

type Command

type Command interface {
	Args() []string
	SessionName() string
}

type Components

type Components struct {
	Paths map[string]string
}

func (*Components) Build

func (c *Components) Build(args ...string)

func (*Components) Cleanup

func (c *Components) Cleanup()

func (*Components) ConfigTxGen

func (c *Components) ConfigTxGen() string

func (*Components) Cryptogen

func (c *Components) Cryptogen() string

func (*Components) Discover

func (c *Components) Discover() string

func (*Components) Idemixgen

func (c *Components) Idemixgen() string

func (*Components) Orderer

func (c *Components) Orderer() string

func (*Components) Peer

func (c *Components) Peer() string

type Config

type Config struct {
	Organizations []*Organization `yaml:"organizations,omitempty"`
	Consortiums   []*Consortium   `yaml:"consortiums,omitempty"`
	SystemChannel *SystemChannel  `yaml:"system_channel,omitempty"`
	Channels      []*Channel      `yaml:"channels,omitempty"`
	Consensus     *Consensus      `yaml:"consensus,omitempty"`
	Orderers      []*Orderer      `yaml:"orderers,omitempty"`
	Peers         []*Peer         `yaml:"peers,omitempty"`
	Profiles      []*Profile      `yaml:"profiles,omitempty"`
	Templates     *Templates      `yaml:"templates,omitempty"`
}

Config holds the basic information needed to generate fabric configuration files.

func BasicEtcdRaft

func BasicEtcdRaft() *Config

func BasicKafka

func BasicKafka() *Config

func BasicSolo

func BasicSolo() *Config

func MinimalRaft

func MinimalRaft() *Config

func MultiChannelEtcdRaft

func MultiChannelEtcdRaft() *Config

func MultiNodeEtcdRaft

func MultiNodeEtcdRaft() *Config

func (*Config) RemovePeer

func (c *Config) RemovePeer(orgName, peerName string)

type Consensus

type Consensus struct {
	Type       string `yaml:"type,omitempty"`
	Brokers    int    `yaml:"brokers,omitempty"`
	ZooKeepers int    `yaml:"zookeepers,omitempty"`
}

Consensus indicates the orderer types and how many broker and zookeeper instances.

type ConsensusMetadataMutator

type ConsensusMetadataMutator func([]byte) []byte

ConsensusMetadataMutator receives ConsensusType.Metadata and mutates it

type Consortium

type Consortium struct {
	Name          string   `yaml:"name,omitempty"`
	Organizations []string `yaml:"organizations,omitempty"`
}

A Consortium is a named collection of Organizations. It is used to populate the Orderer geneesis block profile.

type DiscoveredPeer

type DiscoveredPeer struct {
	MSPID      string   `yaml:"mspid,omitempty"`
	Endpoint   string   `yaml:"endpoint,omitempty"`
	Identity   string   `yaml:"identity,omitempty"`
	Chaincodes []string `yaml:"chaincodes,omitempty"`
}

DiscoveredPeer defines a struct for discovering peers using discovery service. each peer in the result will have these fields

type Enver

type Enver interface {
	Env() []string
}

type Network

type Network struct {
	RootDir           string
	StartPort         uint16
	Components        *Components
	DockerClient      *docker.Client
	NetworkID         string
	EventuallyTimeout time.Duration
	MetricsProvider   string
	StatsdEndpoint    string

	PortsByBrokerID  map[string]Ports
	PortsByOrdererID map[string]Ports
	PortsByPeerID    map[string]Ports
	Organizations    []*Organization
	SystemChannel    *SystemChannel
	Channels         []*Channel
	Consensus        *Consensus
	OrdererCap       *OrdererCapabilities
	Orderers         []*Orderer
	Peers            []*Peer
	Profiles         []*Profile
	Consortiums      []*Consortium
	Templates        *Templates
	// contains filtered or unexported fields
}

Network holds information about a fabric network.

func New

func New(c *Config, rootDir string, client *docker.Client, startPort int, components *Components) *Network

New creates a Network from a simple configuration. All generated or managed artifacts for the network will be located under rootDir. Ports will be allocated sequentially from the specified startPort.

func (*Network) AnchorsForChannel

func (n *Network) AnchorsForChannel(chanName string) []*Peer

AnchorsForChannel returns all Peer instances that are anchors for the named channel.

func (*Network) AnchorsInOrg

func (n *Network) AnchorsInOrg(orgName string) []*Peer

AnchorsInOrg returns all peers that are an anchor for at least one channel in the named organization.

func (*Network) Bootstrap

func (n *Network) Bootstrap()

Bootstrap generates the cryptographic material, orderer system channel genesis block, and create channel transactions needed to run a fabric network.

The cryptogen tool is used to create crypto material from the contents of ${rootDir}/crypto-config.yaml. The generated artifacts will be placed in ${rootDir}/crypto/...

The gensis block is generated from the profile referenced by the SystemChannel.Profile attribute. The block is written to ${rootDir}/${SystemChannel.Name}_block.pb.

The create channel transactions are generated for each Channel referenced by the Network using the channel's Profile attribute. The transactions are written to ${rootDir}/${Channel.Name}_tx.pb.

func (*Network) BrokerAddresses

func (n *Network) BrokerAddresses(portName PortName) []string

BrokerAddresses returns the list of broker addresses for the network.

func (*Network) BrokerGroupRunner

func (n *Network) BrokerGroupRunner() ifrit.Runner

BrokerGroupRunner returns a runner that manages the processes that make up the kafka broker network for fabric.

func (*Network) BrokerRunner

func (n *Network) BrokerRunner(id int, zookeepers []string) *runner.Kafka

BrokerRunner returns a runner for an kafka broker instance.

func (*Network) CACertsBundlePath

func (n *Network) CACertsBundlePath() string

CACertsBundlePath returns the path to the bundle of CA certificates for the network. This bundle is used when connecting to peers.

func (*Network) Cleanup

func (n *Network) Cleanup()

Cleanup attempts to cleanup docker related artifacts that may have been created by the network.

func (*Network) ConcatenateTLSCACertificates

func (n *Network) ConcatenateTLSCACertificates()

concatenateTLSCACertificates concatenates all TLS CA certificates into a single file to be used by peer CLI.

func (*Network) ConfigTxConfigPath

func (n *Network) ConfigTxConfigPath() string

ConfigTxPath returns the path to the generated configtxgen configuration file.

func (*Network) ConfigTxGen

func (n *Network) ConfigTxGen(command Command) (*gexec.Session, error)

ConfigTxGen starts a gexec.Session for the provided configtxgen command.

func (*Network) Consortium

func (n *Network) Consortium(name string) *Consortium

Consortium returns information about the named Consortium.

func (*Network) CreateAndJoinChannel

func (n *Network) CreateAndJoinChannel(o *Orderer, channelName string)

CreateAndJoinChannel will create the specified channel. The referencing peers will then be joined to the channel.

The network must be running before this is called.

func (*Network) CreateAndJoinChannels

func (n *Network) CreateAndJoinChannels(o *Orderer)

CreateAndJoinChannels will create all channels specified in the config that are referenced by peers. The referencing peers will then be joined to the channel(s).

The network must be running before this is called.

func (*Network) CreateChannel

func (n *Network) CreateChannel(channelName string, o *Orderer, p *Peer, additionalSigners ...interface{})

CreateChannel will submit an existing create channel transaction to the specified orderer. The channel transaction must exist at the location returned by CreateChannelTxPath. Optionally, additional signers may be included in the case where the channel creation tx modifies other aspects of the channel config for the new channel.

The orderer must be running when this is called.

func (*Network) CreateChannelFail

func (n *Network) CreateChannelFail(channelName string, o *Orderer, p *Peer, additionalSigners ...interface{})

CreateChannelFail will submit an existing create channel transaction to the specified orderer, but expect to FAIL. The channel transaction must exist at the location returned by CreateChannelTxPath.

The orderer must be running when this is called.

func (*Network) CreateChannelTxPath

func (n *Network) CreateChannelTxPath(channelName string) string

CreateChannelTxPath returns the path to the create channel transaction for the named channel.

func (*Network) CryptoConfigPath

func (n *Network) CryptoConfigPath() string

CryptoConfigPath returns the path to the generated cryptogen configuration file.