github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/discovery/api.go (about)

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