github.com/kaituanwang/hyperledger@v2.0.1+incompatible/discovery/api.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package discovery
     8  
     9  import (
    10  	discprotos "github.com/hyperledger/fabric-protos-go/discovery"
    11  	"github.com/hyperledger/fabric/gossip/api"
    12  	"github.com/hyperledger/fabric/gossip/common"
    13  	"github.com/hyperledger/fabric/gossip/discovery"
    14  	"github.com/hyperledger/fabric/protoutil"
    15  )
    16  
    17  // AccessControlSupport checks if clients are eligible of being serviced
    18  type AccessControlSupport interface {
    19  	// Eligible returns whether the given peer is eligible for receiving
    20  	// service from the discovery service for a given channel
    21  	EligibleForService(channel string, data protoutil.SignedData) error
    22  }
    23  
    24  // ConfigSequenceSupport returns the config sequence of the given channel
    25  type ConfigSequenceSupport interface {
    26  	// ConfigSequence returns the configuration sequence of the a given channel
    27  	ConfigSequence(channel string) uint64
    28  }
    29  
    30  // GossipSupport aggregates abilities that the gossip module
    31  // provides to the discovery service, such as knowing information about peers
    32  type GossipSupport interface {
    33  	// ChannelExists returns whether a given channel exists or not
    34  	ChannelExists(channel string) bool
    35  
    36  	// PeersOfChannel returns the NetworkMembers considered alive
    37  	// and also subscribed to the channel given
    38  	PeersOfChannel(common.ChannelID) discovery.Members
    39  
    40  	// Peers returns the NetworkMembers considered alive
    41  	Peers() discovery.Members
    42  
    43  	// IdentityInfo returns identity information about peers
    44  	IdentityInfo() api.PeerIdentitySet
    45  }
    46  
    47  // EndorsementSupport provides knowledge of endorsement policy selection
    48  // for chaincodes
    49  type EndorsementSupport interface {
    50  	// PeersForEndorsement returns an EndorsementDescriptor for a given set of peers, channel, and chaincode
    51  	PeersForEndorsement(channel common.ChannelID, interest *discprotos.ChaincodeInterest) (*discprotos.EndorsementDescriptor, error)
    52  
    53  	// PeersAuthorizedByCriteria returns the peers of the channel that are authorized by the given chaincode interest
    54  	// That is - taking in account if the chaincode(s) in the interest are installed on the peers, and also
    55  	// taking in account whether the peers are part of the collections of the chaincodes.
    56  	// If a nil interest, or an empty interest is passed - no filtering is done.
    57  	PeersAuthorizedByCriteria(chainID common.ChannelID, interest *discprotos.ChaincodeInterest) (discovery.Members, error)
    58  }
    59  
    60  // ConfigSupport provides access to channel configuration
    61  type ConfigSupport interface {
    62  	// Config returns the channel's configuration
    63  	Config(channel string) (*discprotos.ConfigResult, error)
    64  }
    65  
    66  // Support defines an interface that allows the discovery service
    67  // to obtain information that other peer components have
    68  type Support interface {
    69  	AccessControlSupport
    70  	GossipSupport
    71  	EndorsementSupport
    72  	ConfigSupport
    73  	ConfigSequenceSupport
    74  }