discovery

package
v0.0.0-...-fbe82ab Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//PrioritiesByHeight selects peers by descending height
	PrioritiesByHeight = &byHeight{}
	//NoExclusion接受所有对等方,不拒绝任何对等方
	NoExclusion = selectionFunc(noExclusion)
	//NoPriorities is indifferent to how it selects peers
	NoPriorities = &noPriorities{}
)
View Source
var (
	//errnotfound定义了一个错误,这意味着找不到元素
	ErrNotFound = errors.New("not found")
)

nofilter返回noop筛选器

Functions

This section is empty.

Types

type ChannelResponse

type ChannelResponse interface {
	//config返回对config查询的响应,或者在出现错误时返回错误
	Config() (*discovery.ConfigResult, error)

	//对等方返回对等方成员身份查询的响应,或者在出现错误时返回错误
	Peers(invocationChain ...*discovery.ChaincodeCall) ([]*Peer, error)

	//背书人返回对给定的背书人查询的响应
	//给定通道上下文中的链代码,或者出错时出错。
	//该方法返回一组随机的背书人,以便所有背书人的签名
	//合起来,满足背书政策。
	//选择基于给定的选择提示:
	//筛选:筛选和排序背书人
	//给定的invocationChain指定链码调用(以及集合)
	//客户在构建请求期间通过
	Endorsers(invocationChain InvocationChain, f Filter) (Endorsers, error)
}

通道响应聚合给定通道的响应

type Client

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

客户端与发现服务器交互

func NewClient

func NewClient(createConnection Dialer, s Signer, signerCacheSize uint) *Client

new client创建新的客户端实例

func (*Client) Send

func (c *Client) Send(ctx context.Context, req *Request, auth *discovery.AuthInfo) (Response, error)

发送发送请求并返回响应,或者失败时出错

type Dialer

type Dialer func() (*grpc.ClientConn, error)

拨号程序连接到服务器

type Endorsers

type Endorsers []*Peer

Endorsers defines a set of peers that are sufficient 满足一些链码的认可政策

func (Endorsers) Filter

func (endorsers Endorsers) Filter(f ExclusionFilter) Endorsers

Filter filters the endorsers according to the given ExclusionFilter

func (Endorsers) Shuffle

func (endorsers Endorsers) Shuffle() Endorsers

shuffle按随机顺序对背书人排序

func (Endorsers) Sort

func (endorsers Endorsers) Sort(ps PrioritySelector) Endorsers

根据给定的PrioritySelector对背书人排序

type ExclusionFilter

type ExclusionFilter interface {
	//exclude返回是否排除给定的对等机
	Exclude(Peer) bool
}

如果给定的对等端 is not to be considered when selecting peers

func ExcludeByHost

func ExcludeByHost(reject func(host string) bool) ExclusionFilter

ExcludeByHost creates a ExclusionFilter out of the given exclusion predicate

func ExcludeHosts

func ExcludeHosts(endpoints ...string) ExclusionFilter

excludehosts返回排除给定端点的exclusionfilter

type Filter

type Filter interface {
	Filter(endorsers Endorsers) Endorsers
}

过滤和排序给定的背书人

func NewFilter

func NewFilter(ps PrioritySelector, ef ExclusionFilter) Filter

newfilter返回使用给定排除筛选器和优先级选择器的认可器筛选器 对背书人进行筛选和排序

type InvocationChain

type InvocationChain []*discovery.ChaincodeCall

调用链聚合链编解码器调用

func (InvocationChain) String

func (ic InvocationChain) String() string

字符串返回此调用链的字符串表示形式

func (InvocationChain) ValidateInvocationChain

func (ic InvocationChain) ValidateInvocationChain() error

validateInvocationChain验证InvocationChain的结构

type LocalResponse

type LocalResponse interface {
	//对等方返回本地对等方成员身份查询的响应,或者在出现错误时返回错误
	Peers() ([]*Peer, error)
}

LocalResponse聚合无通道作用域的响应

type MemoizeSigner

type MemoizeSigner struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

memoizesigner使用相同的签名对邮件进行签名 如果邮件是最近签名的

func NewMemoizeSigner

func NewMemoizeSigner(signFunc Signer, maxEntries uint) *MemoizeSigner

NewMemoizeSigner创建一个新的签署MemoizeSigner 具有给定符号功能的消息

func (*MemoizeSigner) Sign

func (ms *MemoizeSigner) Sign(msg []byte) ([]byte, error)

签名者在消息上签名并返回签名和nil, 或零,失败时出错

type Peer

type Peer struct {
	MSPID            string
	AliveMessage     *gossip.SignedGossipMessage
	StateInfoMessage *gossip.SignedGossipMessage
	Identity         []byte
}

对等机聚合身份、成员身份和通道范围的信息 of a certain peer.

type Priority

type Priority int

优先级定义选择对等机的可能性 超过另一个同伴。 正优先级表示选择了左对等 负优先级意味着选择正确的对等体。 零优先级意味着它们的优先级相同

type PrioritySelector

type PrioritySelector interface {
	//比较两个对等点和返回之间的比较
	//他们的相对分数
	Compare(Peer, Peer) Priority
}

PrioritySelector通过 给予同伴相对优先的选择权

type Request

type Request struct {
	*discovery.Request
	// contains filtered or unexported fields
}

请求在其内部聚合多个查询

func NewRequest

func NewRequest() *Request

新建请求创建新请求

func (*Request) AddConfigQuery

func (req *Request) AddConfigQuery() *Request

addconfigquery向请求添加config查询

func (*Request) AddEndorsersQuery

func (req *Request) AddEndorsersQuery(interests ...*discovery.ChaincodeInterest) (*Request, error)

AddEndorsersQuery adds to the request a query for given chaincodes 兴趣是客户想要查询的链码兴趣。 给定通道的所有兴趣都应在聚合切片中提供

func (*Request) AddLocalPeersQuery

func (req *Request) AddLocalPeersQuery() *Request

AddLocalPeersQuery adds to the request a local peer query

func (*Request) AddPeersQuery

func (req *Request) AddPeersQuery(invocationChain ...*discovery.ChaincodeCall) *Request

addpeersquery向请求添加对等查询

func (*Request) OfChannel

func (req *Request) OfChannel(ch string) *Request

ofchannel设置添加到给定通道上下文中的下一个查询

type Response

type Response interface {
	//ForChannel返回给定通道上下文中的ChannelResponse
	ForChannel(string) ChannelResponse

	//forlocal返回无通道上下文中的localresponse
	ForLocal() LocalResponse
}

响应聚合了来自发现服务的多个响应

type Signer

type Signer func(msg []byte) ([]byte, error)

签名者在消息上签名并返回签名和nil, or nil and error on failure

Jump to

Keyboard shortcuts

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