Skip to content

Commit

Permalink
[FAB-9241] Import discovery client
Browse files Browse the repository at this point in the history
This change adds the Fabric discovery client to the pinning scripts.

Change-Id: I4ae8367f5fe9446e200238952a5c0ad58d246ffb
Signed-off-by: Troy Ronda <troy@troyronda.com>
  • Loading branch information
troyronda committed Mar 29, 2018
1 parent 429e1ef commit 0cb0cf9
Show file tree
Hide file tree
Showing 13 changed files with 3,926 additions and 158 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ FABRIC_DEV_REGISTRY_PRE_CMD ?= docker login -u docker -p docker nexus3.hyperledg
THIRDPARTY_FABRIC_CA_BRANCH ?= master
THIRDPARTY_FABRIC_CA_COMMIT ?= v1.1.0
THIRDPARTY_FABRIC_BRANCH ?= master
THIRDPARTY_FABRIC_COMMIT ?= v1.1.0
THIRDPARTY_FABRIC_COMMIT ?= 30806c107fe89e29d6c80b6244a57477242f241f

# Force removal of images in cleanup (overridable)
FIXTURE_DOCKER_REMOVE_FORCE ?= false
Expand Down
71 changes: 71 additions & 0 deletions internal/github.com/hyperledger/fabric/discovery/client/api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
/*
Notice: This file has been modified for Hyperledger Fabric SDK Go usage.
Please review third_party pinning scripts and patches for more details.
*/

package discovery

import (
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/protos/discovery"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/protos/gossip"
"github.com/pkg/errors"
"golang.org/x/net/context"
"google.golang.org/grpc"
)

var (
// ErrNotFound defines an error that means that an element wasn't found
ErrNotFound = errors.New("not found")
)

// Signer signs a message and returns the signature and nil,
// or nil and error on failure
type Signer func(msg []byte) ([]byte, error)

// Dialer connects to the server
type Dialer func() (*grpc.ClientConn, error)

// Client defines the client-side API of the discovery service
type Client interface {
// Send sends the Request and returns the response, or error on failure
Send(context.Context, *Request) (Response, error)
}

// Response aggregates several responses from the discovery service
type Response interface {
// ForChannel returns a ChannelResponse in the context of a given channel
ForChannel(string) ChannelResponse
}

// ChannelResponse aggregates responses for a given channel
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() ([]*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.
Endorsers(string) (Endorsers, error)
}

// Endorsers defines a set of peers that are sufficient
// for satisfying some chaincode's endorsement policy
type Endorsers []*Peer

// Peer aggregates identity, membership and channel-scoped information
// of a certain peer.
type Peer struct {
MSPID string
AliveMessage *gossip.SignedGossipMessage
StateInfoMessage *gossip.SignedGossipMessage
Identity []byte
}
Loading

0 comments on commit 0cb0cf9

Please sign in to comment.