fabric-sdk-go: github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/discovery/client Index | Files

package discovery

import "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/discovery/client"

Index

Package Files

api.go client.go selection.go signer.go

Variables

var (
    // PrioritiesByHeight selects peers by descending height
    PrioritiesByHeight = &byHeight{}
    // NoExclusion accepts all peers and rejects no peers
    NoExclusion = selectionFunc(noExclusion)
    // NoPriorities is indifferent to how it selects peers
    NoPriorities = &noPriorities{}
)
var (
    // ErrNotFound defines an error that means that an element wasn't found
    ErrNotFound = errors.New("not found")
)
var NoFilter = NewFilter(NoPriorities, NoExclusion)

NoFilter returns a noop Filter

type ChannelResponse Uses

type ChannelResponse interface {
    // Config returns a response for a config query, or error if something went wrong
    Config() (*discovery.ConfigResult, error)

    // Peers returns a response for a peer membership query, or error if something went wrong
    Peers(invocationChain ...*discovery.ChaincodeCall) ([]*Peer, error)

    // Endorsers returns the response for an endorser query for a given
    // chaincode in a given channel context, or error if something went wrong.
    // The method returns a random set of endorsers, such that signatures from all of them
    // combined, satisfy the endorsement policy.
    // The selection is based on the given selection hints:
    // Filter: Filters and sorts the endorsers
    // The given InvocationChain specifies the chaincode calls (along with collections)
    // that the client passed during the construction of the request
    Endorsers(invocationChain InvocationChain, f Filter) (Endorsers, error)
}

ChannelResponse aggregates responses for a given channel

type Client Uses

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

Client interacts with the discovery server

func NewClient Uses

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

NewClient creates a new Client instance

func (*Client) Send Uses

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

Send sends the request and returns the response, or error on failure

type Dialer Uses

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

Dialer connects to the server

type Endorsers Uses

type Endorsers []*Peer

Endorsers defines a set of peers that are sufficient for satisfying some chaincode's endorsement policy

func (Endorsers) Filter Uses

func (endorsers Endorsers) Filter(f ExclusionFilter) Endorsers

Filter filters the endorsers according to the given ExclusionFilter

func (Endorsers) Shuffle Uses

func (endorsers Endorsers) Shuffle() Endorsers

Shuffle sorts the endorsers in random order

func (Endorsers) Sort Uses

func (endorsers Endorsers) Sort(ps PrioritySelector) Endorsers

Sort sorts the endorsers according to the given PrioritySelector

type ExclusionFilter Uses

type ExclusionFilter interface {
    // Exclude returns whether the given Peer is to be excluded or not
    Exclude(Peer) bool
}

ExclusionFilter returns true if the given Peer is not to be considered when selecting peers

func ExcludeByHost Uses

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

ExcludeByHost creates a ExclusionFilter out of the given exclusion predicate

func ExcludeHosts Uses

func ExcludeHosts(endpoints ...string) ExclusionFilter

ExcludeHosts returns a ExclusionFilter that excludes the given endpoints

type Filter Uses

type Filter interface {
    Filter(endorsers Endorsers) Endorsers
}

Filter filters and sorts the given endorsers

func NewFilter Uses

func NewFilter(ps PrioritySelector, ef ExclusionFilter) Filter

NewFilter returns an endorser filter that uses the given exclusion filter and priority selector to filter and sort the endorsers

type InvocationChain Uses

type InvocationChain []*discovery.ChaincodeCall

InvocationChain aggregates ChaincodeCalls

func (InvocationChain) String Uses

func (ic InvocationChain) String() string

String returns a string representation of this invocation chain

func (InvocationChain) ValidateInvocationChain Uses

func (ic InvocationChain) ValidateInvocationChain() error

ValidateInvocationChain validates the InvocationChain's structure

type LocalResponse Uses

type LocalResponse interface {
    // Peers returns a response for a local peer membership query, or error if something went wrong
    Peers() ([]*Peer, error)
}

LocalResponse aggregates responses for a channel-less scope

type MemoizeSigner Uses

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

MemoizeSigner signs messages with the same signature if the message was signed recently

func NewMemoizeSigner Uses

func NewMemoizeSigner(signFunc Signer, maxEntries uint) *MemoizeSigner

NewMemoizeSigner creates a new MemoizeSigner that signs message with the given sign function

func (*MemoizeSigner) Sign Uses

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

Signer signs a message and returns the signature and nil, or nil and error on failure

type Peer Uses

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

Peer aggregates identity, membership and channel-scoped information of a certain peer.

type Priority Uses

type Priority int

Priority defines how likely a peer is to be selected over another peer. Positive priority means the left peer is selected Negative priority means the right peer is selected Zero priority means their priorities are the same

type PrioritySelector Uses

type PrioritySelector interface {
    // Compare compares between 2 peers and returns
    // their relative scores
    Compare(Peer, Peer) Priority
}

PrioritySelector guides the selection of peers via giving peers a relative priority to their selection

type Request Uses

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

Request aggregates several queries inside it

func NewRequest Uses

func NewRequest() *Request

NewRequest creates a new request

func (*Request) AddConfigQuery Uses

func (req *Request) AddConfigQuery() *Request

AddConfigQuery adds to the request a config query

func (*Request) AddEndorsersQuery Uses

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

AddEndorsersQuery adds to the request a query for given chaincodes interests are the chaincode interests that the client wants to query for. All interests for a given channel should be supplied in an aggregated slice

func (*Request) AddLocalPeersQuery Uses

func (req *Request) AddLocalPeersQuery() *Request

AddLocalPeersQuery adds to the request a local peer query

func (*Request) AddPeersQuery Uses

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

AddPeersQuery adds to the request a peer query

func (*Request) OfChannel Uses

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

OfChannel sets the next queries added to be in the given channel's context

type Response Uses

type Response interface {
    // ForChannel returns a ChannelResponse in the context of a given channel
    ForChannel(string) ChannelResponse

    // ForLocal returns a LocalResponse in the context of no channel
    ForLocal() LocalResponse
}

Response aggregates several responses from the discovery service

type Signer Uses

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

Signer signs a message and returns the signature and nil, or nil and error on failure

Package discovery imports 16 packages (graph) and is imported by 4 packages. Updated 2019-08-26. Refresh now. Tools for package owners.