Documentation ¶
Overview ¶
Package multichannel tracks the channel resources for the orderer. It initially loads the set of existing channels, and provides an interface for users of these channels to retrieve them, or create new ones.
Index ¶
- func ConfigBlockOrPanic(reader blockledger.Reader) *cb.Block
- func InitJoinBlockFileRepo(config *localconfig.TopLevel) (*filerepo.Repo, error)
- type BlockWriter
- func (bw *BlockWriter) CreateNextBlock(messages []*cb.Envelope) *cb.Block
- func (bw *BlockWriter) WriteBlock(block *cb.Block, encodedMetadataValue []byte)
- func (bw *BlockWriter) WriteBlockSync(block *cb.Block, encodedMetadataValue []byte)
- func (bw *BlockWriter) WriteConfigBlock(block *cb.Block, encodedMetadataValue []byte)
- type ChainSupport
- func (cs *ChainSupport) Append(block *cb.Block) error
- func (lr ChainSupport) Block(number uint64) *common.Block
- func (cs *ChainSupport) BlockCutter() blockcutter.Receiver
- func (lr ChainSupport) ChannelID() string
- func (cs *ChainSupport) ConfigProto() *cb.Config
- func (cs *ChainSupport) ProposeConfigUpdate(configtx *cb.Envelope) (*cb.ConfigEnvelope, error)
- func (cs *ChainSupport) Reader() blockledger.Reader
- func (cs *ChainSupport) Sequence() uint64
- func (cs *ChainSupport) Signer() identity.SignerSerializer
- func (cs *ChainSupport) Validate(configEnv *cb.ConfigEnvelope) error
- func (lr ChainSupport) VerifyBlockSignature(sd []*protoutil.SignedData, envelope *common.ConfigEnvelope) error
- type Metrics
- type MetricsProvider
- type Registrar
- func (r *Registrar) BroadcastChannelSupport(msg *cb.Envelope) (*cb.ChannelHeader, bool, *ChainSupport, error)
- func (r *Registrar) ChannelInfo(channelID string) (types.ChannelInfo, error)
- func (r *Registrar) ChannelList() types.ChannelList
- func (r *Registrar) ChannelsCount() int
- func (r *Registrar) CreateBundle(channelID string, config *cb.Config) (channelconfig.Resources, error)
- func (r *Registrar) CreateChain(chainName string)
- func (r *Registrar) GetChain(chainID string) *ChainSupport
- func (r *Registrar) GetConsensusChain(chainID string) consensus.Chain
- func (r *Registrar) GetFollower(chainID string) *follower.Chain
- func (r *Registrar) Initialize(consenters map[string]consensus.Consenter)
- func (r *Registrar) JoinChannel(channelID string, configBlock *cb.Block, isAppChannel bool) (info types.ChannelInfo, err error)
- func (r *Registrar) NewChannelConfig(envConfigUpdate *cb.Envelope) (channelconfig.Resources, error)
- func (r *Registrar) RemoveChannel(channelID string) error
- func (r *Registrar) ReportConsensusRelationAndStatusMetrics(channelID string, relation types.ConsensusRelation, status types.Status)
- func (r *Registrar) SwitchChainToFollower(channelName string)
- func (r *Registrar) SwitchFollowerToChain(channelID string)
- func (r *Registrar) SystemChannel() *ChainSupport
- func (r *Registrar) SystemChannelID() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigBlockOrPanic ¶
func ConfigBlockOrPanic(reader blockledger.Reader) *cb.Block
ConfigBlockOrPanic retrieves the last configuration block from the given ledger. Panics on failure.
func InitJoinBlockFileRepo ¶
func InitJoinBlockFileRepo(config *localconfig.TopLevel) (*filerepo.Repo, error)
InitJoinBlockFileRepo initialize the channel participation API joinblock file repo. This creates the fileRepoDir on the filesystem if it does not already exist.
Types ¶
type BlockWriter ¶
type BlockWriter struct {
// contains filtered or unexported fields
}
BlockWriter efficiently writes the blockchain to disk. To safely use BlockWriter, only one thread should interact with it. BlockWriter will spawn additional committing go routines and handle locking so that these other go routines safely interact with the calling one.
func (*BlockWriter) CreateNextBlock ¶
func (bw *BlockWriter) CreateNextBlock(messages []*cb.Envelope) *cb.Block
CreateNextBlock creates a new block with the next block number, and the given contents.
func (*BlockWriter) WriteBlock ¶
func (bw *BlockWriter) WriteBlock(block *cb.Block, encodedMetadataValue []byte)
WriteBlock should be invoked for blocks which contain normal transactions. It sets the target block as the pending next block, and returns before it is committed. Before returning, it acquires the committing lock, and spawns a go routine which will annotate the block with metadata and signatures, and write the block to the ledger then release the lock. This allows the calling thread to begin assembling the next block before the commit phase is complete.
func (*BlockWriter) WriteBlockSync ¶
func (bw *BlockWriter) WriteBlockSync(block *cb.Block, encodedMetadataValue []byte)
WriteBlockSync is same as WriteBlock, but commits block synchronously. Note: WriteConfigBlock should use WriteBlockSync instead of WriteBlock.
If the block contains a transaction that remove the node from consenters, the node will switch to follower and pull blocks from other nodes. Suppose writing block asynchronously, the block maybe not persist to disk when the follower chain starts working. The follower chain will read a block before the config block, in which the node is still a consenter, so the follower chain will switch to the consensus chain. That's a dead loop! So WriteConfigBlock should use WriteBlockSync instead of WriteBlock.
func (*BlockWriter) WriteConfigBlock ¶
func (bw *BlockWriter) WriteConfigBlock(block *cb.Block, encodedMetadataValue []byte)
WriteConfigBlock should be invoked for blocks which contain a config transaction. This call will block until the new config has taken effect, then will return while the block is written asynchronously to disk.
type ChainSupport ¶
type ChainSupport struct { msgprocessor.Processor *BlockWriter consensus.Chain identity.SignerSerializer BCCSP bccsp.BCCSP // NOTE: It makes sense to add this to the ChainSupport since the design of Registrar does not assume // that there is a single consensus type at this orderer node and therefore the resolution of // the consensus type too happens only at the ChainSupport level. consensus.MetadataValidator // The registrar is not aware of the exact type that the Chain is, e.g. etcdraft, inactive, or follower. // Therefore, we let each chain report its cluster relation and status through this interface. Non cluster // type chains (solo, kafka) are assigned a static reporter. consensus.StatusReporter // contains filtered or unexported fields }
ChainSupport holds the resources for a particular channel.
func (*ChainSupport) Append ¶
func (cs *ChainSupport) Append(block *cb.Block) error
Append appends a new block to the ledger in its raw form, unlike WriteBlock that also mutates its metadata.
func (ChainSupport) Block ¶
Block returns a block with the following number, or nil if such a block doesn't exist.
func (*ChainSupport) BlockCutter ¶
func (cs *ChainSupport) BlockCutter() blockcutter.Receiver
BlockCutter returns the blockcutter.Receiver instance for this channel.
func (ChainSupport) ChannelID ¶
func (lr ChainSupport) ChannelID() string
ChannelID passes through to the underlying configtx.Validator
func (*ChainSupport) ConfigProto ¶
func (cs *ChainSupport) ConfigProto() *cb.Config
ConfigProto passes through to the underlying configtx.Validator
func (*ChainSupport) ProposeConfigUpdate ¶
func (cs *ChainSupport) ProposeConfigUpdate(configtx *cb.Envelope) (*cb.ConfigEnvelope, error)
ProposeConfigUpdate validates a config update using the underlying configtx.Validator and the consensus.MetadataValidator.
func (*ChainSupport) Reader ¶
func (cs *ChainSupport) Reader() blockledger.Reader
func (*ChainSupport) Sequence ¶
func (cs *ChainSupport) Sequence() uint64
Sequence passes through to the underlying configtx.Validator
func (*ChainSupport) Signer ¶
func (cs *ChainSupport) Signer() identity.SignerSerializer
Signer returns the SignerSerializer for this channel.
func (*ChainSupport) Validate ¶
func (cs *ChainSupport) Validate(configEnv *cb.ConfigEnvelope) error
Validate passes through to the underlying configtx.Validator
func (ChainSupport) VerifyBlockSignature ¶
func (lr ChainSupport) VerifyBlockSignature(sd []*protoutil.SignedData, envelope *common.ConfigEnvelope) error
VerifyBlockSignature verifies a signature of a block. It has an optional argument of a configuration envelope which would make the block verification to use validation rules based on the given configuration in the ConfigEnvelope. If the config envelope passed is nil, then the validation rules used are the ones that were applied at commit of previous blocks.
type Metrics ¶
Metrics defines the metrics for the cluster.
func NewMetrics ¶
func NewMetrics(m MetricsProvider) *Metrics
NewMetrics initializes new metrics for the channel participation API.
type MetricsProvider ¶
type MetricsProvider interface { // NewCounter creates a new instance of a Counter. NewCounter(opts metrics.CounterOpts) metrics.Counter // NewGauge creates a new instance of a Gauge. NewGauge(opts metrics.GaugeOpts) metrics.Gauge // NewHistogram creates a new instance of a Histogram. NewHistogram(opts metrics.HistogramOpts) metrics.Histogram }
A MetricsProvider is an abstraction for a metrics provider. It is a factory for Counter, Gauge, and Histogram meters.
type Registrar ¶
type Registrar struct {
// contains filtered or unexported fields
}
Registrar serves as a point of access and control for the individual channel resources.
func NewRegistrar ¶
func NewRegistrar( config localconfig.TopLevel, ledgerFactory blockledger.Factory, signer identity.SignerSerializer, metricsProvider metrics.Provider, bccsp bccsp.BCCSP, clusterDialer *cluster.PredicateDialer, callbacks ...channelconfig.BundleActor) *Registrar
NewRegistrar produces an instance of a *Registrar.
func (*Registrar) BroadcastChannelSupport ¶
func (r *Registrar) BroadcastChannelSupport(msg *cb.Envelope) (*cb.ChannelHeader, bool, *ChainSupport, error)
BroadcastChannelSupport returns the message channel header, whether the message is a config update and the channel resources for a message or an error if the message is not a message which can be processed directly (like CONFIG and ORDERER_TRANSACTION messages)
func (*Registrar) ChannelInfo ¶
func (r *Registrar) ChannelInfo(channelID string) (types.ChannelInfo, error)
ChannelInfo provides extended status information about a channel. The URL field is empty, and is to be completed by the caller.
func (*Registrar) ChannelList ¶
func (r *Registrar) ChannelList() types.ChannelList
ChannelList returns a slice of ChannelInfoShort containing all application channels (excluding the system channel), and ChannelInfoShort of the system channel (nil if does not exist). The URL fields are empty, and are to be completed by the caller.
func (*Registrar) ChannelsCount ¶
ChannelsCount returns the count of the current total number of channels.
func (*Registrar) CreateBundle ¶
func (r *Registrar) CreateBundle(channelID string, config *cb.Config) (channelconfig.Resources, error)
CreateBundle calls channelconfig.NewBundle
func (*Registrar) CreateChain ¶
CreateChain makes the Registrar create a consensus.Chain with the given name.
func (*Registrar) GetChain ¶
func (r *Registrar) GetChain(chainID string) *ChainSupport
GetChain retrieves the chain support for a chain if it exists.
func (*Registrar) GetConsensusChain ¶
GetConsensusChain retrieves the consensus.Chain of the channel, if it exists.
func (*Registrar) GetFollower ¶
GetFollower retrieves the follower.Chain if it exists.
func (*Registrar) Initialize ¶
func (*Registrar) JoinChannel ¶
func (r *Registrar) JoinChannel(channelID string, configBlock *cb.Block, isAppChannel bool) (info types.ChannelInfo, err error)
JoinChannel instructs the orderer to create a channel and join it with the provided config block. The URL field is empty, and is to be completed by the caller.
func (*Registrar) NewChannelConfig ¶
NewChannelConfig produces a new template channel configuration based on the system channel's current config.
func (*Registrar) RemoveChannel ¶
RemoveChannel instructs the orderer to remove a channel.
func (*Registrar) ReportConsensusRelationAndStatusMetrics ¶
func (*Registrar) SwitchChainToFollower ¶
SwitchChainToFollower creates a follower.Chain from the tip of the ledger and removes the consensus.Chain. It is called when an etcdraft.Chain detects it was evicted from the cluster (i.e. removed from the consenters set) and halts, transferring execution to the follower.Chain.
func (*Registrar) SwitchFollowerToChain ¶
SwitchFollowerToChain creates a consensus.Chain from the tip of the ledger, and removes the follower. It is called when a follower detects a config block that indicates cluster membership and halts, transferring execution to the consensus.Chain.
func (*Registrar) SystemChannel ¶
func (r *Registrar) SystemChannel() *ChainSupport
SystemChannel returns the ChainSupport for the system channel.
func (*Registrar) SystemChannelID ¶
SystemChannelID returns the ChannelID for the system channel.