Skip to content

Commit

Permalink
[FAB-9537] Import Discovery Client Local Peers
Browse files Browse the repository at this point in the history
Change-Id: I487ec243c8de9caa89089a9c88d96964917ea1a0
Signed-off-by: Bob Stasyszyn <Bob.Stasyszyn@securekey.com>
  • Loading branch information
bstasyszyn committed Apr 16, 2018
1 parent 041e8e1 commit 6c1b8bc
Show file tree
Hide file tree
Showing 9 changed files with 372 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 ?= 68f268379c78cabbd4325fc2e40059a8c46912ae
THIRDPARTY_FABRIC_COMMIT ?= a8cc2c46d8cec1ad199741c0630a46ccb24084ac

# Force removal of images in cleanup (overridable)
FIXTURE_DOCKER_REMOVE_FORCE ?= false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (

// PeerLedgerProvider provides handle to ledger instances
type PeerLedgerProvider interface {
Initialize(statelisteners StateListeners)
Initialize(statelisteners []StateListener)
// Create creates a new ledger with the given genesis block.
// This function guarantees that the creation of ledger and committing the genesis block would an atomic action
// The chain id retrieved from the genesis block is treated as a ledger id
Expand Down Expand Up @@ -271,6 +271,8 @@ func (txSim *TxSimulationResults) ContainsPvtWrites() bool {
return txSim.PvtSimulationResults != nil
}

//go:generate counterfeiter -o mock/state_listener.go -fake-name StateListener . StateListener

// StateListener allows a custom code for performing additional stuff upon state change
// for a perticular namespace against which the listener is registered.
// This helps to perform custom tasks other than the state updates.
Expand All @@ -283,11 +285,10 @@ func (txSim *TxSimulationResults) ContainsPvtWrites() bool {
// function returns an error, the ledger implementation is expected to halt block commit operation
// and result in a panic
type StateListener interface {
HandleStateUpdates(ledgerID string, stateUpdates StateUpdates) error
InterestedInNamespaces() []string
HandleStateUpdates(ledgerID string, stateUpdates StateUpdates, committingBlockNum uint64) error
StateCommitDone(channelID string)
}

// StateUpdates is the generic type to represent the state updates
type StateUpdates interface{}

// StateListeners maintains the association between a namespace to its corresponding listener
type StateListeners map[string]StateListener
type StateUpdates map[string]interface{}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ 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"
)

Expand All @@ -30,16 +29,13 @@ 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

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

// ChannelResponse aggregates responses for a given channel
Expand All @@ -54,7 +50,16 @@ type ChannelResponse interface {
// 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)
// The selection is based on the given selection hints:
// PrioritySelector: Determines which endorsers are selected over others
// ExclusionFilter: Determines which endorsers are not selected
Endorsers(cc string, ps PrioritySelector, ef ExclusionFilter) (Endorsers, error)
}

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

// Endorsers defines a set of peers that are sufficient
Expand Down
Loading

0 comments on commit 6c1b8bc

Please sign in to comment.