Documentation ¶
Overview ¶
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 Start() // Halt frees the resources which were allocated for this Chain Halt() }
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{} // 是否有错误发生? broadcast.Support // 处理交易输入 ConsenterSupport // 共识机制帮助方法 // Sequence returns the current config sequence number Sequence() uint64 // + 1 // 交易转换(配置交易) // Envelope 信封(交易信封) // 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 { crypto.LocalSigner // 签名 BlockCutter() blockcutter.Receiver // 区块切割对象 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 // 链的配置 (new / update) 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