multichain

package
v0.0.0-...-c5686b1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

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
	// 和配置相关对链的配置更改,则会加1
	Sequence() uint64

	// ProposeConfigUpdate applies a CONFIG_UPDATE to an existing config to produce a *cb.ConfigEnvelope
	// 将一个交易转换成配置交易
	// Envelope本意是信封(orderer从客户端处获取交易,但不会对交易做有效性的验证,就是指他从客户端获取的交易只是一个信封)
	// 交易的具体内容是被封装在信封里的 orderer节点是不会展开Envepole,不会对交易进行处理,只会对交易进行转发
	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                                                                // 区块切割对象(将fabric交易切割成区块)
	SharedConfig() config.Orderer                                                                     // 配置
	CreateNextBlock(messages []*cb.Envelope) *cb.Block                                                // 将切割好的交易,打包成区块
	WriteBlock(block *cb.Block, committers []filter.Committer, encodedMetadataValue []byte) *cb.Block // 写入临时区块
	// 链ID
	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)
	// 获取链对象,不是直接对链对象操作,而是对ChainSupport操作
	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 manager实例化

Jump to

Keyboard shortcuts

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