v1.0.6 Latest Latest

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

Go to latest
Published: Feb 18, 2018 License: Apache-2.0 Imports: 18 Imported by: 0



Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0



This section is empty.


This section is empty.


This section is empty.


type Chain

type Chain interface {
	// Enqueue accepts a message and returns true on acceptance, or false on failure
	Enqueue(env *cb.Envelope) bool

	// Errored returns a channel which will close when an error has occurred
	// This is especially useful for the Deliver client, who must terminate waiting
	// clients when the consenter is not up to date
	Errored() <-chan struct{}

	// Start should allocate whatever resources are needed for staying up to date with the chain
	// Typically, this involves creating a thread which reads from the ordering source, passes those
	// messages to a block cutter, and writes the resulting blocks to the ledger

	// Halt frees the resources which were allocated for this Chain

Chain defines a way to inject messages for ordering Note, that in order to allow flexibility in the implementation, it is the responsibility of the implementer to take the ordered messages, send them through the blockcutter.Receiver supplied via HandleChain to cut blocks, and ultimately write the ledger also supplied via HandleChain. This flow allows for two primary flows 1. Messages are ordered into a stream, the stream is cut into blocks, the blocks are committed (solo, kafka) 2. Messages are cut into blocks, the blocks are ordered, then the blocks are committed (sbft)

type ChainSupport

type ChainSupport interface {

	// PolicyManager returns the current policy manager as specified by the chain config
	PolicyManager() policies.Manager

	// Reader returns the chain Reader for the chain
	Reader() ledger.Reader

	// Errored returns whether the backing consenter has errored
	Errored() <-chan struct{}


	// Sequence returns the current config sequence number
	Sequence() uint64

	// ProposeConfigUpdate applies a CONFIG_UPDATE to an existing config to produce a *cb.ConfigEnvelope
	ProposeConfigUpdate(env *cb.Envelope) (*cb.ConfigEnvelope, error)

ChainSupport provides a wrapper for the resources backing a chain

type Consenter

type Consenter interface {
	// HandleChain should create and return a reference to a Chain for the given set of resources
	// It will only be invoked for a given chain once per process.  In general, errors will be treated
	// as irrecoverable and cause system shutdown.  See the description of Chain for more details
	// The second argument to HandleChain is a pointer to the metadata stored on the `ORDERER` slot of
	// the last block committed to the ledger of this Chain.  For a new chain, this metadata will be
	// nil, as this field is not set on the genesis block
	HandleChain(support ConsenterSupport, metadata *cb.Metadata) (Chain, error)

Consenter defines the backing ordering mechanism

type ConsenterSupport

type ConsenterSupport interface {
	BlockCutter() blockcutter.Receiver
	SharedConfig() config.Orderer
	CreateNextBlock(messages []*cb.Envelope) *cb.Block
	WriteBlock(block *cb.Block, committers []filter.Committer, encodedMetadataValue []byte) *cb.Block
	ChainID() string // ChainID returns the chain ID this specific consenter instance is associated with
	Height() uint64  // Returns the number of blocks on the chain this specific consenter instance is associated with

ConsenterSupport provides the resources available to a Consenter implementation

type Manager

type Manager interface {
	// GetChain retrieves the chain support for a chain (and whether it exists)
	GetChain(chainID string) (ChainSupport, bool)

	// SystemChannelID returns the channel ID for the system channel
	SystemChannelID() string

	// NewChannelConfig returns a bare bones configuration ready for channel
	// creation request to be applied on top of it
	NewChannelConfig(envConfigUpdate *cb.Envelope) (configtxapi.Manager, error)

Manager coordinates the creation and access of chains

func NewManagerImpl

func NewManagerImpl(ledgerFactory ledger.Factory, consenters map[string]Consenter, signer crypto.LocalSigner) Manager

NewManagerImpl produces an instance of a Manager

Jump to

Keyboard shortcuts

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