config

package
v1.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2017 License: Apache-2.0 Imports: 19 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Note, the directory is still configvalues, but this is stuttery and config is a more accurate and better name, TODO, update directory

Index

Constants

View Source
const (
	// HashingAlgorithmKey is the cb.ConfigItem type key name for the HashingAlgorithm message
	HashingAlgorithmKey = "HashingAlgorithm"

	// BlockDataHashingStructureKey is the cb.ConfigItem type key name for the BlockDataHashingStructure message
	BlockDataHashingStructureKey = "BlockDataHashingStructure"

	// OrdererAddressesKey is the cb.ConfigItem type key name for the OrdererAddresses message
	OrdererAddressesKey = "OrdererAddresses"

	// GroupKey is the name of the channel group
	ChannelGroupKey = "Channel"
)

Channel config keys

View Source
const (
	// ConsensusTypeKey is the cb.ConfigItem type key name for the ConsensusType message
	ConsensusTypeKey = "ConsensusType"

	// BatchSizeKey is the cb.ConfigItem type key name for the BatchSize message
	BatchSizeKey = "BatchSize"

	// BatchTimeoutKey is the cb.ConfigItem type key name for the BatchTimeout message
	BatchTimeoutKey = "BatchTimeout"

	// ChainCreationPolicyNamesKey is the cb.ConfigItem type key name for the ChainCreationPolicyNames message
	ChainCreationPolicyNamesKey = "ChainCreationPolicyNames"

	// ChannelRestrictions is the key name for the ChannelRestrictions message
	ChannelRestrictionsKey = "ChannelRestrictions"

	// KafkaBrokersKey is the cb.ConfigItem type key name for the KafkaBrokers message
	KafkaBrokersKey = "KafkaBrokers"
)
View Source
const (
	// AnchorPeersKey is the key name for the AnchorPeers ConfigValue
	AnchorPeersKey = "AnchorPeers"
)

Application org config keys

View Source
const (
	// ApplicationGroupKey is the group name for the Application config
	ApplicationGroupKey = "Application"
)
View Source
const (
	// MSPKey is value key for marshaled *mspconfig.MSPConfig
	MSPKey = "MSP"
)

Org config keys

View Source
const (
	// OrdererGroupKey is the group name for the orderer config
	OrdererGroupKey = "Orderer"
)

Variables

This section is empty.

Functions

func DefaultBlockDataHashingStructure

func DefaultBlockDataHashingStructure() *cb.ConfigGroup

DefaultBlockDatahashingStructure creates a headerless config item for the default block data hashing structure

func DefaultHashingAlgorithm

func DefaultHashingAlgorithm() *cb.ConfigGroup

DefaultHashingAlgorithm creates a headerless config item for the default hashing algorithm

func DefaultOrdererAddresses

func DefaultOrdererAddresses() *cb.ConfigGroup

DefaultOrdererAddresses creates a headerless config item for the default orderer addresses

func NewStandardValues

func NewStandardValues(protosStructs ...interface{}) (*standardValues, error)

NewStandardValues accepts a structure which must contain only protobuf message types. The structure may embed other (non-pointer) structures which satisfy the same condition. NewStandard values will instantiate memory for all the proto messages and build a lookup map from structure field name to proto message instance This is a useful way to easily implement the Values interface

func TemplateAnchorPeers

func TemplateAnchorPeers(orgID string, anchorPeers []*pb.AnchorPeer) *cb.ConfigGroup

TemplateAnchorPeers creates a headerless config item representing the anchor peers

func TemplateBatchSize

func TemplateBatchSize(batchSize *ab.BatchSize) *cb.ConfigGroup

TemplateBatchSize creates a headerless config item representing the batch size

func TemplateBatchTimeout

func TemplateBatchTimeout(batchTimeout string) *cb.ConfigGroup

TemplateBatchTimeout creates a headerless config item representing the batch timeout

func TemplateBlockDataHashingStructure

func TemplateBlockDataHashingStructure(width uint32) *cb.ConfigGroup

TemplateBlockDataHashingStructure creates a headerless config item representing the block data hashing structure

func TemplateChainCreationPolicyNames

func TemplateChainCreationPolicyNames(names []string) *cb.ConfigGroup

TemplateChainCreationPolicyNames creates a headerless configuraiton item representing the chain creation policy names

func TemplateChannelRestrictions

func TemplateChannelRestrictions(maxChannels uint64) *cb.ConfigGroup

TemplateChannelRestrictions creates a config group with ChannelRestrictions specified

func TemplateConsensusType

func TemplateConsensusType(typeValue string) *cb.ConfigGroup

TemplateConsensusType creates a headerless config item representing the consensus type

func TemplateHashingAlgorithm

func TemplateHashingAlgorithm(name string) *cb.ConfigGroup

TemplateHashingAlgorithm creates a ConfigGroup representing the HashingAlgorithm

func TemplateKafkaBrokers

func TemplateKafkaBrokers(brokers []string) *cb.ConfigGroup

TemplateKafkaBrokers creates a headerless config item representing the kafka brokers

func TemplateOrdererAddresses

func TemplateOrdererAddresses(addresses []string) *cb.ConfigGroup

TemplateOrdererAddressess creates a headerless config item representing the orderer addresses

Types

type Application

type Application interface {
	// Organizations returns a map of org ID to ApplicationOrg
	Organizations() map[string]ApplicationOrg
}

Application stores the common shared application config

type ApplicationConfig

type ApplicationConfig struct {
	// contains filtered or unexported fields
}

func NewApplicationConfig

func NewApplicationConfig(ag *ApplicationGroup) *ApplicationConfig

func (*ApplicationConfig) Commit

func (ac *ApplicationConfig) Commit()

func (ApplicationConfig) Deserialize

func (sv ApplicationConfig) Deserialize(key string, value []byte) (proto.Message, error)

Deserialize looks up the backing Values proto of the given name, unmarshals the given bytes to populate the backing message structure, and retuns a referenced to the retained deserialized message (or an error, either because the key did not exist, or there was an an error unmarshaling

func (*ApplicationConfig) Organizations

func (ac *ApplicationConfig) Organizations() map[string]ApplicationOrg

Organizations returns a map of org ID to ApplicationOrg

func (*ApplicationConfig) Validate

func (ac *ApplicationConfig) Validate(tx interface{}, groups map[string]ValueProposer) error

type ApplicationGroup

type ApplicationGroup struct {
	*Proposer
	*ApplicationConfig
	// contains filtered or unexported fields
}

ApplicationGroup represents the application config group

func NewApplicationGroup

func NewApplicationGroup(mspConfig *msp.MSPConfigHandler) *ApplicationGroup

NewSharedConfigImpl creates a new SharedConfigImpl with the given CryptoHelper

func (*ApplicationGroup) Allocate

func (ag *ApplicationGroup) Allocate() Values

Allocate returns a new instance of the ApplicationConfig

func (ApplicationGroup) Deserialize

func (sv ApplicationGroup) Deserialize(key string, value []byte) (proto.Message, error)

Deserialize looks up the backing Values proto of the given name, unmarshals the given bytes to populate the backing message structure, and retuns a referenced to the retained deserialized message (or an error, either because the key did not exist, or there was an an error unmarshaling

func (*ApplicationGroup) NewGroup

func (ag *ApplicationGroup) NewGroup(name string) (ValueProposer, error)

type ApplicationOrg

type ApplicationOrg interface {
	Org

	// AnchorPeers returns the list of gossip anchor peers
	AnchorPeers() []*pb.AnchorPeer
}

ApplicationOrg stores the per org application config

type ApplicationOrgConfig

type ApplicationOrgConfig struct {
	*OrganizationConfig
	// contains filtered or unexported fields
}

func NewApplicationOrgConfig

func NewApplicationOrgConfig(aog *ApplicationOrgGroup) *ApplicationOrgConfig

func (*ApplicationOrgConfig) AnchorPeers

func (aog *ApplicationOrgConfig) AnchorPeers() []*pb.AnchorPeer

AnchorPeers returns the list of valid orderer addresses to connect to to invoke Broadcast/Deliver

func (*ApplicationOrgConfig) Commit

func (aoc *ApplicationOrgConfig) Commit()

func (ApplicationOrgConfig) Deserialize

func (sv ApplicationOrgConfig) Deserialize(key string, value []byte) (proto.Message, error)

Deserialize looks up the backing Values proto of the given name, unmarshals the given bytes to populate the backing message structure, and retuns a referenced to the retained deserialized message (or an error, either because the key did not exist, or there was an an error unmarshaling

func (*ApplicationOrgConfig) Validate

func (aoc *ApplicationOrgConfig) Validate(tx interface{}, groups map[string]ValueProposer) error

type ApplicationOrgGroup

type ApplicationOrgGroup struct {
	*Proposer
	*OrganizationGroup
	*ApplicationOrgConfig
}

ApplicationOrgGroup defines the configuration for an application org

func NewApplicationOrgGroup

func NewApplicationOrgGroup(id string, mspConfig *mspconfig.MSPConfigHandler) *ApplicationOrgGroup

NewApplicationOrgGroup creates a new ApplicationOrgGroup

func (*ApplicationOrgGroup) Allocate

func (aog *ApplicationOrgGroup) Allocate() Values

type ApplicationOrgProtos

type ApplicationOrgProtos struct {
	AnchorPeers *pb.AnchorPeers
}

type Channel

type Channel interface {
	// HashingAlgorithm returns the default algorithm to be used when hashing
	// such as computing block hashes, and CreationPolicy digests
	HashingAlgorithm() func(input []byte) []byte

	// BlockDataHashingStructureWidth returns the width to use when constructing the
	// Merkle tree to compute the BlockData hash
	BlockDataHashingStructureWidth() uint32

	// OrdererAddresses returns the list of valid orderer addresses to connect to to invoke Broadcast/Deliver
	OrdererAddresses() []string
}

Channel gives read only access to the channel configuration

type ChannelConfig

type ChannelConfig struct {
	// contains filtered or unexported fields
}

ChannelConfig stores the channel configuration

func NewChannelConfig

func NewChannelConfig() *ChannelConfig

NewChannelConfig creates a new ChannelConfig

func (*ChannelConfig) BlockDataHashingStructureWidth

func (cc *ChannelConfig) BlockDataHashingStructureWidth() uint32

BlockDataHashingStructure returns the width to use when forming the block data hashing structure

func (ChannelConfig) Deserialize

func (sv ChannelConfig) Deserialize(key string, value []byte) (proto.Message, error)

Deserialize looks up the backing Values proto of the given name, unmarshals the given bytes to populate the backing message structure, and retuns a referenced to the retained deserialized message (or an error, either because the key did not exist, or there was an an error unmarshaling

func (*ChannelConfig) HashingAlgorithm

func (cc *ChannelConfig) HashingAlgorithm() func(input []byte) []byte

HashingAlgorithm returns a function pointer to the chain hashing algorihtm

func (*ChannelConfig) OrdererAddresses

func (cc *ChannelConfig) OrdererAddresses() []string

OrdererAddresses returns the list of valid orderer addresses to connect to to invoke Broadcast/Deliver

func (*ChannelConfig) Validate

func (cc *ChannelConfig) Validate(tx interface{}, groups map[string]ValueProposer) error

Validate inspects the generated configuration protos, ensures that the values are correct, and sets the ChannelConfig fields that may be referenced after Commit

type ChannelGroup

type ChannelGroup struct {
	*ChannelConfig
	*Proposer
	// contains filtered or unexported fields
}

ChannelGroup

func NewChannelGroup

func NewChannelGroup(mspConfigHandler *msp.MSPConfigHandler) *ChannelGroup

func (*ChannelGroup) Allocate

func (cg *ChannelGroup) Allocate() Values

Allocate creates new config resources for a pending config update

func (*ChannelGroup) ApplicationConfig

func (cg *ChannelGroup) ApplicationConfig() *ApplicationGroup

ApplicationConfig returns the application config associated with this channel

func (ChannelGroup) Deserialize

func (sv ChannelGroup) Deserialize(key string, value []byte) (proto.Message, error)

Deserialize looks up the backing Values proto of the given name, unmarshals the given bytes to populate the backing message structure, and retuns a referenced to the retained deserialized message (or an error, either because the key did not exist, or there was an an error unmarshaling

func (*ChannelGroup) NewGroup

func (cg *ChannelGroup) NewGroup(group string) (ValueProposer, error)

NewGroup instantiates either a new application or orderer config

func (*ChannelGroup) OrdererConfig

func (cg *ChannelGroup) OrdererConfig() *OrdererGroup

OrdererConfig returns the orderer config associated with this channel

type ChannelProtos

type ChannelProtos struct {
	HashingAlgorithm          *cb.HashingAlgorithm
	BlockDataHashingStructure *cb.BlockDataHashingStructure
	OrdererAddresses          *cb.OrdererAddresses
}

ChannelProtos is where the proposed configuration is unmarshaled into

type ChannelValues

type ChannelValues interface {
	// HashingAlgorithm returns the default algorithm to be used when hashing
	// such as computing block hashes, and CreationPolicy digests
	HashingAlgorithm() func(input []byte) []byte

	// BlockDataHashingStructureWidth returns the width to use when constructing the
	// Merkle tree to compute the BlockData hash
	BlockDataHashingStructureWidth() uint32

	// OrdererAddresses returns the list of valid orderer addresses to connect to to invoke Broadcast/Deliver
	OrdererAddresses() []string
}

ChannelValues gives read only access to the channel configuration

type Handler

type Handler interface {
	Allocate() Values
	NewGroup(name string) (ValueProposer, error)
}

Handler

type Orderer

type Orderer interface {
	// ConsensusType returns the configured consensus type
	ConsensusType() string

	// BatchSize returns the maximum number of messages to include in a block
	BatchSize() *ab.BatchSize

	// BatchTimeout returns the amount of time to wait before creating a batch
	BatchTimeout() time.Duration

	// ChainCreationPolicyNames returns the policy names which are allowed for chain creation
	// This field is only set for the system ordering chain
	ChainCreationPolicyNames() []string

	// MaxChannelsCount returns the maximum count of channels to allow for an ordering network
	MaxChannelsCount() uint64

	// KafkaBrokers returns the addresses (IP:port notation) of a set of "bootstrap"
	// Kafka brokers, i.e. this is not necessarily the entire set of Kafka brokers
	// used for ordering
	KafkaBrokers() []string
}

Orderer stores the common shared orderer config

type OrdererConfig

type OrdererConfig struct {
	// contains filtered or unexported fields
}

OrdererConfig holds the orderer configuration information

func NewOrdererConfig

func NewOrdererConfig(og *OrdererGroup) *OrdererConfig

NewOrdererConfig creates a new instance of the orderer config

func (*OrdererConfig) BatchSize

func (oc *OrdererConfig) BatchSize() *ab.BatchSize

BatchSize returns the maximum number of messages to include in a block

func (*OrdererConfig) BatchTimeout

func (oc *OrdererConfig) BatchTimeout() time.Duration

BatchTimeout returns the amount of time to wait before creating a batch

func (*OrdererConfig) ChainCreationPolicyNames

func (oc *OrdererConfig) ChainCreationPolicyNames() []string

ChainCreationPolicyNames returns the policy names which are allowed for chain creation This field is only set for the system ordering chain

func (*OrdererConfig) Commit

func (oc *OrdererConfig) Commit()

Commit writes the orderer config back to the orderer config group

func (*OrdererConfig) ConsensusType

func (oc *OrdererConfig) ConsensusType() string

ConsensusType returns the configured consensus type

func (OrdererConfig) Deserialize

func (sv OrdererConfig) Deserialize(key string, value []byte) (proto.Message, error)

Deserialize looks up the backing Values proto of the given name, unmarshals the given bytes to populate the backing message structure, and retuns a referenced to the retained deserialized message (or an error, either because the key did not exist, or there was an an error unmarshaling

func (*OrdererConfig) KafkaBrokers

func (oc *OrdererConfig) KafkaBrokers() []string

KafkaBrokers returns the addresses (IP:port notation) of a set of "bootstrap" Kafka brokers, i.e. this is not necessarily the entire set of Kafka brokers used for ordering

func (*OrdererConfig) MaxChannelsCount

func (oc *OrdererConfig) MaxChannelsCount() uint64

MaxChannelsCount returns the maximum count of channels this orderer supports

func (*OrdererConfig) Validate

func (oc *OrdererConfig) Validate(tx interface{}, groups map[string]ValueProposer) error

type OrdererGroup

type OrdererGroup struct {
	*Proposer
	*OrdererConfig
	// contains filtered or unexported fields
}

Config is stores the orderer component configuration

func NewOrdererGroup

func NewOrdererGroup(mspConfig *msp.MSPConfigHandler) *OrdererGroup

NewConfig creates a new *OrdererConfig

func (*OrdererGroup) Allocate

func (og *OrdererGroup) Allocate() Values

func (OrdererGroup) Deserialize

func (sv OrdererGroup) Deserialize(key string, value []byte) (proto.Message, error)

Deserialize looks up the backing Values proto of the given name, unmarshals the given bytes to populate the backing message structure, and retuns a referenced to the retained deserialized message (or an error, either because the key did not exist, or there was an an error unmarshaling

func (*OrdererGroup) NewGroup

func (og *OrdererGroup) NewGroup(name string) (ValueProposer, error)

NewGroup returns an Org instance

type OrdererProtos

type OrdererProtos struct {
	ConsensusType            *ab.ConsensusType
	BatchSize                *ab.BatchSize
	BatchTimeout             *ab.BatchTimeout
	ChainCreationPolicyNames *ab.ChainCreationPolicyNames
	KafkaBrokers             *ab.KafkaBrokers
	CreationPolicy           *ab.CreationPolicy
	ChannelRestrictions      *ab.ChannelRestrictions
}

OrdererProtos is used as the source of the OrdererConfig

type Org

type Org interface {
	// Name returns the name this org is referred to in config
	Name() string

	// MSPID returns the MSP ID associated with this org
	MSPID() string
}

Org stores the common organizational config

type OrganizationConfig

type OrganizationConfig struct {
	// contains filtered or unexported fields
}

func NewOrganizationConfig

func NewOrganizationConfig(og *OrganizationGroup) *OrganizationConfig

func (*OrganizationConfig) Commit

func (oc *OrganizationConfig) Commit()

func (OrganizationConfig) Deserialize

func (sv OrganizationConfig) Deserialize(key string, value []byte) (proto.Message, error)

Deserialize looks up the backing Values proto of the given name, unmarshals the given bytes to populate the backing message structure, and retuns a referenced to the retained deserialized message (or an error, either because the key did not exist, or there was an an error unmarshaling

func (*OrganizationConfig) Validate

func (oc *OrganizationConfig) Validate(tx interface{}, groups map[string]ValueProposer) error

Validate returns whether the configuration is valid

type OrganizationGroup

type OrganizationGroup struct {
	*Proposer
	*OrganizationConfig
	// contains filtered or unexported fields
}

Config stores common configuration information for organizations

func NewOrganizationGroup

func NewOrganizationGroup(name string, mspConfigHandler *mspconfig.MSPConfigHandler) *OrganizationGroup

NewConfig creates an instnace of the organization Config

func (*OrganizationGroup) Allocate

func (og *OrganizationGroup) Allocate() Values

Allocate creates the proto resources neeeded for a proposal

func (OrganizationGroup) Deserialize

func (sv OrganizationGroup) Deserialize(key string, value []byte) (proto.Message, error)

Deserialize looks up the backing Values proto of the given name, unmarshals the given bytes to populate the backing message structure, and retuns a referenced to the retained deserialized message (or an error, either because the key did not exist, or there was an an error unmarshaling

func (*OrganizationGroup) MSPID

func (og *OrganizationGroup) MSPID() string

MSPID returns the MSP ID associated with this org

func (*OrganizationGroup) Name

func (og *OrganizationGroup) Name() string

Name returns the name this org is referred to in config

func (*OrganizationGroup) NewGroup

func (og *OrganizationGroup) NewGroup(name string) (ValueProposer, error)

NewGroup always errors

type OrganizationProtos

type OrganizationProtos struct {
	MSP *mspprotos.MSPConfig
}

type Proposer

type Proposer struct {
	// contains filtered or unexported fields
}

func NewProposer

func NewProposer(vh Handler) *Proposer

func (*Proposer) BeginValueProposals

func (p *Proposer) BeginValueProposals(tx interface{}, groups []string) (ValueDeserializer, []ValueProposer, error)

BeginValueProposals called when a config proposal is begun

func (*Proposer) CommitProposals

func (p *Proposer) CommitProposals(tx interface{})

CommitProposals called when a config proposal is committed

func (*Proposer) PreCommit

func (p *Proposer) PreCommit(tx interface{}) error

Validate ensures that the new config values is a valid change

func (*Proposer) RollbackProposals

func (p *Proposer) RollbackProposals(tx interface{})

RollbackProposals called when a config proposal is abandoned

type Root

type Root struct {
	// contains filtered or unexported fields
}

Root acts as the object which anchors the rest of the config Note, yes, this is a stuttering name, but, the intent is to move this up one level at the end of refactoring

func NewRoot

func NewRoot(mspConfigHandler *msp.MSPConfigHandler) *Root

NewRoot creates a new instance of the Root

func (*Root) Application

func (r *Root) Application() *ApplicationGroup

Application returns the associated Application level config

func (*Root) BeginValueProposals

func (r *Root) BeginValueProposals(tx interface{}, groups []string) (ValueDeserializer, []ValueProposer, error)

BeginValueProposals is used to start a new config proposal

func (*Root) Channel

func (r *Root) Channel() *ChannelGroup

Channel returns the associated Channel level config

func (*Root) CommitProposals

func (r *Root) CommitProposals(tx interface{})

CommitConfig is used to commit a new config proposal

func (*Root) Orderer

func (r *Root) Orderer() *OrdererGroup

Orderer returns the associated Orderer level config

func (*Root) PreCommit

func (r *Root) PreCommit(tx interface{}) error

PreCommit is used to verify total configuration before commit

func (*Root) RollbackProposals

func (r *Root) RollbackProposals(tx interface{})

RollbackConfig is used to abandon a new config proposal

type ValueDeserializer

type ValueDeserializer interface {
	// Deserialize takes a Value key as a string, and a marshaled Value value as bytes
	// and returns the deserialized version of that value.  Note, this function operates
	// with side effects intended.  Using a ValueDeserializer to deserialize a message will
	// generally set the value in the Values interface that the ValueDeserializer derived from
	// Therefore, the proto.Message may be safely discarded, but may be retained for
	// inspection and or debugging purposes.
	Deserialize(key string, value []byte) (proto.Message, error)
}

ValueDeserializer provides a mechanism to retrieve proto messages to deserialize config values into

type ValueProposer

type ValueProposer interface {
	// BeginValueProposals called when a config proposal is begun
	BeginValueProposals(tx interface{}, groups []string) (ValueDeserializer, []ValueProposer, error)

	// RollbackProposals called when a config proposal is abandoned
	RollbackProposals(tx interface{})

	// PreCommit is invoked before committing the config to catch
	// any errors which cannot be caught on a per proposal basis
	// TODO, rename other methods to remove Value/Proposal references
	PreCommit(tx interface{}) error

	// CommitProposals called when a config proposal is committed
	CommitProposals(tx interface{})
}

type Values

type Values interface {
	ValueDeserializer

	// Validate should ensure that the values set into the proto messages are correct
	// and that the new group values are allowed.  It also includes a tx ID in case cross
	// Handler invocations (ie to the MSP Config Manager) must be made
	Validate(interface{}, map[string]ValueProposer) error

	// Commit should call back into the Value handler to update the config
	Commit()
}

Values defines a mechanism to supply messages to unamrshal from config and a mechanism to validate the results

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL