Commit 1c3296c3 authored by Gari Singh's avatar Gari Singh Committed by Gerrit Code Review
Browse files

Merge "[FAB-10963] Discovery: filtering in membership queries"

parents d92412ca ae9237f3
......@@ -11,7 +11,7 @@ import (
"github.com/hyperledger/fabric/gossip/common"
"github.com/hyperledger/fabric/gossip/discovery"
common2 "github.com/hyperledger/fabric/protos/common"
discovery2 "github.com/hyperledger/fabric/protos/discovery"
discprotos "github.com/hyperledger/fabric/protos/discovery"
)
// AccessControlSupport checks if clients are eligible of being serviced
......@@ -50,13 +50,19 @@ type GossipSupport interface {
// for chaincodes
type EndorsementSupport interface {
// PeersForEndorsement returns an EndorsementDescriptor for a given set of peers, channel, and chaincode
PeersForEndorsement(channel common.ChainID, interest *discovery2.ChaincodeInterest) (*discovery2.EndorsementDescriptor, error)
PeersForEndorsement(channel common.ChainID, interest *discprotos.ChaincodeInterest) (*discprotos.EndorsementDescriptor, error)
// PeersAuthorizedByCriteria returns the peers of the channel that are authorized by the given chaincode interest
// That is - taking in account if the chaincode(s) in the interest are installed on the peers, and also
// taking in account whether the peers are part of the collections of the chaincodes.
// If a nil interest, or an empty interest is passed - no filtering is done.
PeersAuthorizedByCriteria(chainID common.ChainID, interest *discprotos.ChaincodeInterest) (discovery.Members, error)
}
// ConfigSupport provides access to channel configuration
type ConfigSupport interface {
// Config returns the channel's configuration
Config(channel string) (*discovery2.ConfigResult, error)
Config(channel string) (*discprotos.ConfigResult, error)
}
// Support defines an interface that allows the discovery service
......
......@@ -40,7 +40,7 @@ type ChannelResponse interface {
Config() (*discovery.ConfigResult, error)
// Peers returns a response for a peer membership query, or error if something went wrong
Peers() ([]*Peer, error)
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.
......
......@@ -10,6 +10,7 @@ import (
"bytes"
"context"
"encoding/json"
"fmt"
"math/rand"
"time"
......@@ -105,24 +106,38 @@ func (req *Request) AddLocalPeersQuery() *Request {
req.Queries = append(req.Queries, &discovery.Query{
Query: q,
})
req.addQueryMapping(discovery.LocalMembershipQueryType, "")
var ic InvocationChain
req.addQueryMapping(discovery.LocalMembershipQueryType, channnelAndInvocationChain("", ic))
return req
}
// AddPeersQuery adds to the request a peer query
func (req *Request) AddPeersQuery() *Request {
func (req *Request) AddPeersQuery(invocationChain ...*discovery.ChaincodeCall) *Request {
ch := req.lastChannel
q := &discovery.Query_PeerQuery{
PeerQuery: &discovery.PeerMembershipQuery{},
PeerQuery: &discovery.PeerMembershipQuery{
Filter: &discovery.ChaincodeInterest{
Chaincodes: invocationChain,
},
},
}
req.Queries = append(req.Queries, &discovery.Query{
Channel: ch,
Query: q,
})
req.addQueryMapping(discovery.PeerMembershipQueryType, ch)
var ic InvocationChain
if len(invocationChain) > 0 {
ic = InvocationChain(invocationChain)
}
req.addChaincodeQueryMapping([]InvocationChain{ic})
req.addQueryMapping(discovery.PeerMembershipQueryType, channnelAndInvocationChain(ch, ic))
return req
}
func channnelAndInvocationChain(ch string, ic InvocationChain) string {
return fmt.Sprintf("%s %s", ch, ic.String())
}
// OfChannel sets the next queries added to be in the given channel's context
func (req *Request) OfChannel(ch string) *Request {
req.lastChannel = ch
......@@ -204,7 +219,7 @@ type channelResponse struct {
func (cr *channelResponse) Config() (*discovery.ConfigResult, error) {
res, exists := cr.response[key{
queryType: discovery.ConfigQueryType,
channel: cr.channel,
k: cr.channel,
}]
if !exists {
......@@ -218,11 +233,12 @@ func (cr *channelResponse) Config() (*discovery.ConfigResult, error) {
return nil, res.(error)
}
func parsePeers(queryType discovery.QueryType, r response, channel string) ([]*Peer, error) {
res, exists := r[key{
func parsePeers(queryType discovery.QueryType, r response, channel string, invocationChain ...*discovery.ChaincodeCall) ([]*Peer, error) {
peerKeys := key{
queryType: queryType,
channel: channel,
}]
k: fmt.Sprintf("%s %s", channel, InvocationChain(invocationChain).String()),
}
res, exists := r[peerKeys]
if !exists {
return nil, ErrNotFound
......@@ -235,8 +251,8 @@ func parsePeers(queryType discovery.QueryType, r response, channel string) ([]*P
return nil, res.(error)
}
func (cr *channelResponse) Peers() ([]*Peer, error) {
return parsePeers(discovery.PeerMembershipQueryType, cr.response, cr.channel)
func (cr *channelResponse) Peers(invocationChain ...*discovery.ChaincodeCall) ([]*Peer, error) {
return parsePeers(discovery.PeerMembershipQueryType, cr.response, cr.channel, invocationChain...)
}
func (cr *channelResponse) Endorsers(invocationChain InvocationChain, ps PrioritySelector, ef ExclusionFilter) (Endorsers, error) {
......@@ -244,7 +260,7 @@ func (cr *channelResponse) Endorsers(invocationChain InvocationChain, ps Priorit
// it means it's an error returned from the service
if err, exists := cr.response[key{
queryType: discovery.ChaincodeQueryType,
channel: cr.channel,
k: cr.channel,
}]; exists {
return nil, err.(error)
}
......@@ -252,7 +268,7 @@ func (cr *channelResponse) Endorsers(invocationChain InvocationChain, ps Priorit
// Else, the service returned a response that isn't an error
res, exists := cr.response[key{
queryType: discovery.ChaincodeQueryType,
channel: cr.channel,
k: cr.channel,
invocationChain: invocationChain.String(),
}]
......@@ -306,7 +322,7 @@ func (resp response) ForChannel(ch string) ChannelResponse {
type key struct {
queryType discovery.QueryType
channel string
k string
invocationChain string
}
......@@ -318,7 +334,7 @@ func (req *Request) computeResponse(r *discovery.Response) (response, error) {
case discovery.ConfigQueryType:
err = resp.mapConfig(channel2index, r)
case discovery.ChaincodeQueryType:
err = resp.mapEndorsers(channel2index, r, req.queryMapping, req.invocationChainMapping)
err = resp.mapEndorsers(channel2index, r, req.invocationChainMapping)
case discovery.PeerMembershipQueryType:
err = resp.mapPeerMembership(channel2index, r, discovery.PeerMembershipQueryType)
case discovery.LocalMembershipQueryType:
......@@ -340,7 +356,7 @@ func (resp response) mapConfig(channel2index map[string]int, r *discovery.Respon
}
key := key{
queryType: discovery.ConfigQueryType,
channel: ch,
k: ch,
}
if err != nil {
......@@ -353,15 +369,16 @@ func (resp response) mapConfig(channel2index map[string]int, r *discovery.Respon
return nil
}
func (resp response) mapPeerMembership(channel2index map[string]int, r *discovery.Response, qt discovery.QueryType) error {
for ch, index := range channel2index {
func (resp response) mapPeerMembership(key2Index map[string]int, r *discovery.Response, qt discovery.QueryType) error {
for k, index := range key2Index {
membersRes, err := r.MembershipAt(index)
if membersRes == nil && err == nil {
return errors.Errorf("expected QueryResult of either PeerMembershipResult or Error but got %v instead", r.Results[index])
}
key := key{
queryType: qt,
channel: ch,
k: k,
}
if err != nil {
......@@ -418,7 +435,6 @@ func isStateInfoExpected(qt discovery.QueryType) bool {
func (resp response) mapEndorsers(
channel2index map[string]int,
r *discovery.Response,
queryMapping map[discovery.QueryType]map[string]int,
chaincodeQueryMapping map[int][]InvocationChain) error {
for ch, index := range channel2index {
ccQueryRes, err := r.EndorsersAt(index)
......@@ -429,7 +445,7 @@ func (resp response) mapEndorsers(
if err != nil {
key := key{
queryType: discovery.ChaincodeQueryType,
channel: ch,
k: ch,
}
resp[key] = errors.New(err.Content)
continue
......@@ -453,7 +469,7 @@ func (resp response) mapEndorsersOfChannel(ccRs *discovery.ChaincodeQueryResult,
}
key := key{
queryType: discovery.ChaincodeQueryType,
channel: channel,
k: channel,
invocationChain: invocationChain[i].String(),
}
......
......@@ -27,7 +27,7 @@ import (
"github.com/hyperledger/fabric/discovery/endorsement"
"github.com/hyperledger/fabric/gossip/api"
gossipcommon "github.com/hyperledger/fabric/gossip/common"
discovery3 "github.com/hyperledger/fabric/gossip/discovery"
gdisc "github.com/hyperledger/fabric/gossip/discovery"
"github.com/hyperledger/fabric/protos/common"
"github.com/hyperledger/fabric/protos/discovery"
"github.com/hyperledger/fabric/protos/gossip"
......@@ -101,7 +101,7 @@ var (
},
}
channelPeersWithChaincodes = discovery3.Members{
channelPeersWithChaincodes = gdisc.Members{
newPeer(0, stateInfoMessage(cc, cc2), propertiesWithChaincodes).NetworkMember,
newPeer(1, stateInfoMessage(cc, cc2), propertiesWithChaincodes).NetworkMember,
newPeer(2, stateInfoMessage(cc, cc2), propertiesWithChaincodes).NetworkMember,
......@@ -112,7 +112,7 @@ var (
newPeer(7, stateInfoMessage(cc, cc2), propertiesWithChaincodes).NetworkMember,
}
channelPeersWithoutChaincodes = discovery3.Members{
channelPeersWithoutChaincodes = gdisc.Members{
newPeer(0, stateInfoMessage(), nil).NetworkMember,
newPeer(1, stateInfoMessage(), nil).NetworkMember,
newPeer(2, stateInfoMessage(), nil).NetworkMember,
......@@ -123,7 +123,7 @@ var (
newPeer(7, stateInfoMessage(), nil).NetworkMember,
}
membershipPeers = discovery3.Members{
membershipPeers = gdisc.Members{
newPeer(0, aliveMessage(0), nil).NetworkMember,
newPeer(1, aliveMessage(1), nil).NetworkMember,
newPeer(2, aliveMessage(2), nil).NetworkMember,
......@@ -422,6 +422,22 @@ func TestClient(t *testing.T) {
assert.Contains(t, expectedOrgCombinations2, getMSPs(endorsers))
})
t.Run("Peer membership query with collections and chaincodes", func(t *testing.T) {
sup.On("PeersOfChannel").Return(channelPeersWithChaincodes).Once()
interest := ccCall("mycc2")
interest[0].CollectionNames = append(interest[0].CollectionNames, "col")
req = NewRequest().OfChannel("mychannel").AddPeersQuery(interest...)
r, err = cl.Send(ctx, req, authInfo)
assert.NoError(t, err)
mychannel := r.ForChannel("mychannel")
peers, err := mychannel.Peers(interest...)
assert.NoError(t, err)
// We should see all peers that aren't in ORG A since it's not part of the collection
for _, p := range peers {
assert.NotEqual(t, "A", p.MSPID)
}
assert.Len(t, peers, 6)
})
}
func TestUnableToSign(t *testing.T) {
......@@ -692,6 +708,8 @@ func (pf *policyFetcher) PolicyByChaincode(channel string, cc string) policies.I
type endorsementAnalyzer interface {
PeersForEndorsement(chainID gossipcommon.ChainID, interest *discovery.ChaincodeInterest) (*discovery.EndorsementDescriptor, error)
PeersAuthorizedByCriteria(chainID gossipcommon.ChainID, interest *discovery.ChaincodeInterest) (gdisc.Members, error)
}
type inquireablePolicy struct {
......@@ -734,7 +752,7 @@ func peerIdentity(mspID string, i int) api.PeerIdentityInfo {
type peerInfo struct {
identity api.PeerIdentityType
pkiID gossipcommon.PKIidType
discovery3.NetworkMember
gdisc.NetworkMember
}
func aliveMessage(id int) *gossip.Envelope {
......@@ -778,7 +796,7 @@ func newPeer(i int, env *gossip.Envelope, properties *gossip.Properties) *peerIn
return &peerInfo{
pkiID: gossipcommon.PKIidType(p),
identity: api.PeerIdentityType(p),
NetworkMember: discovery3.NetworkMember{
NetworkMember: gdisc.NetworkMember{
PKIid: gossipcommon.PKIidType(p),
Endpoint: p,
InternalEndpoint: p,
......@@ -808,18 +826,22 @@ func (*mockSupport) ChannelExists(channel string) bool {
return true
}
func (ms *mockSupport) PeersOfChannel(gossipcommon.ChainID) discovery3.Members {
return ms.Called().Get(0).(discovery3.Members)
func (ms *mockSupport) PeersOfChannel(gossipcommon.ChainID) gdisc.Members {
return ms.Called().Get(0).(gdisc.Members)
}
func (ms *mockSupport) Peers() discovery3.Members {
return ms.Called().Get(0).(discovery3.Members)
func (ms *mockSupport) Peers() gdisc.Members {
return ms.Called().Get(0).(gdisc.Members)
}
func (ms *mockSupport) PeersForEndorsement(channel gossipcommon.ChainID, interest *discovery.ChaincodeInterest) (*discovery.EndorsementDescriptor, error) {
return ms.endorsementAnalyzer.PeersForEndorsement(channel, interest)
}
func (ms *mockSupport) PeersAuthorizedByCriteria(channel gossipcommon.ChainID, interest *discovery.ChaincodeInterest) (gdisc.Members, error) {
return ms.endorsementAnalyzer.PeersAuthorizedByCriteria(channel, interest)
}
func (*mockSupport) EligibleForService(channel string, data common.SignedData) error {
return nil
}
......
// Code generated by mockery v1.0.0
// Code generated by mockery v1.0.0. DO NOT EDIT.
package mocks
import client "github.com/hyperledger/fabric/discovery/client"
......@@ -56,13 +56,19 @@ func (_m *ChannelResponse) Endorsers(invocationChain client.InvocationChain, ps
return r0, r1
}
// Peers provides a mock function with given fields:
func (_m *ChannelResponse) Peers() ([]*client.Peer, error) {
ret := _m.Called()
// Peers provides a mock function with given fields: invocationChain
func (_m *ChannelResponse) Peers(invocationChain ...*discovery.ChaincodeCall) ([]*client.Peer, error) {
_va := make([]interface{}, len(invocationChain))
for _i := range invocationChain {
_va[_i] = invocationChain[_i]
}
var _ca []interface{}
_ca = append(_ca, _va...)
ret := _m.Called(_ca...)
var r0 []*client.Peer
if rf, ok := ret.Get(0).(func() []*client.Peer); ok {
r0 = rf()
if rf, ok := ret.Get(0).(func(...*discovery.ChaincodeCall) []*client.Peer); ok {
r0 = rf(invocationChain...)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]*client.Peer)
......@@ -70,8 +76,8 @@ func (_m *ChannelResponse) Peers() ([]*client.Peer, error) {
}
var r1 error
if rf, ok := ret.Get(1).(func() error); ok {
r1 = rf()
if rf, ok := ret.Get(1).(func(...*discovery.ChaincodeCall) error); ok {
r1 = rf(invocationChain...)
} else {
r1 = ret.Error(1)
}
......
// Code generated by mockery v1.0.0
// Code generated by mockery v1.0.0. DO NOT EDIT.
package mocks
import common "github.com/hyperledger/fabric/cmd/common"
......
// Code generated by mockery v1.0.0
// Code generated by mockery v1.0.0. DO NOT EDIT.
package mocks
import discovery "github.com/hyperledger/fabric/discovery/client"
......
// Code generated by mockery v1.0.0
// Code generated by mockery v1.0.0. DO NOT EDIT.
package mocks
import discovery "github.com/hyperledger/fabric/discovery/cmd"
......
// Code generated by mockery v1.0.0
// Code generated by mockery v1.0.0. DO NOT EDIT.
package mocks
import discovery "github.com/hyperledger/fabric/discovery/client"
......
// Code generated by mockery v1.0.0
// Code generated by mockery v1.0.0. DO NOT EDIT.
package mocks
import cmd "github.com/hyperledger/fabric/discovery/cmd"
......
......@@ -83,7 +83,7 @@ func (parser *PeerResponseParser) ParseResponse(channel string, res ServiceRespo
if channel == "" {
listPeers = res.ForLocal()
} else {
listPeers = res.ForChannel(channel)
listPeers = &simpleChannelResponse{res.ForChannel(channel)}
}
peers, err := listPeers.Peers()
if err != nil {
......@@ -112,6 +112,14 @@ type peerLister interface {
Peers() ([]*discovery.Peer, error)
}
type simpleChannelResponse struct {
discovery.ChannelResponse
}
func (scr *simpleChannelResponse) Peers() ([]*discovery.Peer, error) {
return scr.ChannelResponse.Peers()
}
func rawPeerToPeer(p *discovery.Peer) peer {
var ledgerHeight uint64
var ccs []string
......
......@@ -114,7 +114,6 @@ func (s *service) processQuery(query *discovery.Query, request *discovery.Signed
return accessDenied
}
return s.dispatch(query)
}
func (s *service) dispatch(q *discovery.Query) *discovery.QueryResult {
......@@ -177,8 +176,11 @@ func wrapPeerResponse(peersByOrg map[string]*discovery.Peers) *discovery.QueryRe
}
func (s *service) channelMembershipResponse(q *discovery.Query) *discovery.QueryResult {
chanPeers, err := s.PeersAuthorizedByCriteria(common2.ChainID(q.Channel), q.GetPeerQuery().Filter)
if err != nil {
return wrapError(err)
}
membersByOrgs := make(map[string]*discovery.Peers)
chanPeers := s.PeersOfChannel(common2.ChainID(q.Channel))
chanPeerByID := discovery2.Members(chanPeers).ByID()
for org, ids2Peers := range s.computeMembership(q) {
membersByOrgs[org] = &discovery.Peers{}
......@@ -207,7 +209,7 @@ func (s *service) localMembershipResponse(q *discovery.Query) *discovery.QueryRe
return wrapPeerResponse(membersByOrgs)
}
func (s *service) computeMembership(q *discovery.Query) map[string]peerMapping {
func (s *service) computeMembership(_ *discovery.Query) map[string]peerMapping {
peersByOrg := make(map[string]peerMapping)
peerAliveInfo := discovery2.Members(s.Peers()).ByID()
for org, peerIdentities := range s.IdentityInfo().ByOrg() {
......
......@@ -14,8 +14,8 @@ import (
"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric/gossip/api"
common2 "github.com/hyperledger/fabric/gossip/common"
discovery2 "github.com/hyperledger/fabric/gossip/discovery"
gcommon "github.com/hyperledger/fabric/gossip/common"
gdisc "github.com/hyperledger/fabric/gossip/discovery"
"github.com/hyperledger/fabric/protos/common"
"github.com/hyperledger/fabric/protos/discovery"
"github.com/hyperledger/fabric/protos/gossip"
......@@ -57,8 +57,10 @@ func TestService(t *testing.T) {
mockSup.On("ChannelExists", "noneExistentChannel").Return(false)
mockSup.On("ChannelExists", "channelWithAccessDenied").Return(true)
mockSup.On("ChannelExists", "channelWithAccessGranted").Return(true)
mockSup.On("ChannelExists", "channelWithSomeProblem").Return(true)
mockSup.On("EligibleForService", "channelWithAccessDenied", mock.Anything).Return(errors.New("foo"))
mockSup.On("EligibleForService", "channelWithAccessGranted", mock.Anything).Return(nil)
mockSup.On("EligibleForService", "channelWithSomeProblem", mock.Anything).Return(nil)
ed1 := &discovery.EndorsementDescriptor{
Chaincode: "cc1",
}
......@@ -207,15 +209,16 @@ func TestService(t *testing.T) {
// So that means that the returned peers for the channel should be the intersection
// which is: {p1, p2}, but the returned peers for the local query should be
// simply the membership view.
peersInMembershipView := discovery2.Members{
peersInMembershipView := gdisc.Members{
aliveMsg(0), aliveMsg(1), aliveMsg(2), aliveMsg(3),
}
peersInChannelView := discovery2.Members{
peersInChannelView := gdisc.Members{
stateInfoMsg(1), stateInfoMsg(2), stateInfoMsg(4),
}
// EligibleForService for an "empty" channel
mockSup.On("EligibleForService", "", mock.Anything).Return(nil).Once()
mockSup.On("PeersOfChannel", common2.ChainID("channelWithAccessGranted")).Return(peersInChannelView).Once()
mockSup.On("PeersAuthorizedByCriteria", gcommon.ChainID("channelWithAccessGranted")).Return(peersInChannelView, nil).Once()
mockSup.On("PeersAuthorizedByCriteria", gcommon.ChainID("channelWithSomeProblem")).Return(nil, errors.New("an error occurred")).Once()
mockSup.On("Peers").Return(peersInMembershipView).Twice()
mockSup.On("IdentityInfo").Return(api.PeerIdentitySet{
idInfo(0, "O2"), idInfo(1, "O2"), idInfo(2, "O3"),
......@@ -234,6 +237,14 @@ func TestService(t *testing.T) {
LocalPeers: &discovery.LocalPeerQuery{},
},
},
{
Channel: "channelWithSomeProblem",
Query: &discovery.Query_PeerQuery{
PeerQuery: &discovery.PeerMembershipQuery{
Filter: &discovery.ChaincodeInterest{},
},
},
},
}
resp, err = service.Discover(ctx, toSignedRequest(req))
expectedChannelResponse := &discovery.PeerMembershipResult{
......@@ -287,9 +298,10 @@ func TestService(t *testing.T) {
},
}
assert.Len(t, resp.Results, 2)
assert.Len(t, resp.Results, 3)
assert.Len(t, resp.Results[0].GetMembers().PeersByOrg, 2)
assert.Len(t, resp.Results[1].GetMembers().PeersByOrg, 2)
assert.Equal(t, "an error occurred", resp.Results[2].GetError().Content)
for org, responsePeers := range resp.Results[0].GetMembers().PeersByOrg {
err := peers(expectedChannelResponse.PeersByOrg[org].Peers).compare(peers(responsePeers.Peers))
......@@ -484,15 +496,15 @@ func (ms *mockSupport) ChannelExists(channel string) bool {
return ms.Called(channel).Get(0).(bool)
}
func (ms *mockSupport) PeersOfChannel(channel common2.ChainID) discovery2.Members {
return ms.Called(channel).Get(0).(discovery2.Members)
func (ms *mockSupport) PeersOfChannel(channel gcommon.ChainID) gdisc.Members {
panic("not implemented")
}
func (ms *mockSupport) Peers() discovery2.Members {
return ms.Called().Get(0).(discovery2.Members)
func (ms *mockSupport) Peers() gdisc.Members {
return ms.Called().Get(0).(gdisc.Members)
}
func (ms *mockSupport) PeersForEndorsement(channel common2.ChainID, interest *discovery.ChaincodeInterest) (*discovery.EndorsementDescriptor, error) {
func (ms *mockSupport) PeersForEndorsement(channel gcommon.ChainID, interest *discovery.ChaincodeInterest) (*discovery.EndorsementDescriptor, error) {
cc := interest.Chaincodes[0].Name
args := ms.Called(cc)
if args.Get(0) == nil {
......@@ -501,7 +513,15 @@ func (ms *mockSupport) PeersForEndorsement(channel common2.ChainID, interest *di
return args.Get(0).(*discovery.EndorsementDescriptor), args.Error(1)
}
func (*mockSupport) Chaincodes(id common2.ChainID) []*gossip.Chaincode {
func (ms *mockSupport) PeersAuthorizedByCriteria(chainID gcommon.ChainID, interest *discovery.ChaincodeInterest) (gdisc.Members, error) {
args := ms.Called(chainID)
if args.Error(1) != nil {
return nil, args.Error(1)
}
return args.Get(0).(gdisc.Members), args.Error(1)
}
func (*mockSupport) Chaincodes(id gcommon.ChainID) []*gossip.Chaincode {
panic("implement me")
}
......@@ -520,15 +540,15 @@ func (ms *mockSupport) Config(channel string) (*discovery.ConfigResult, error) {
func idInfo(id int, org string) api.PeerIdentityInfo {
endpoint := fmt.Sprintf("p%d", id)
return api.PeerIdentityInfo{
PKIId: common2.PKIidType(endpoint),
PKIId: gcommon.PKIidType(endpoint),
Organization: api.OrgIdentityType(org),
Identity: api.PeerIdentityType(endpoint),
}
}
func stateInfoMsg(id int) discovery2.NetworkMember {
func stateInfoMsg(id int) gdisc.NetworkMember {
endpoint := fmt.Sprintf("p%d", id)
pkiID := common2.PKIidType(endpoint)
pkiID := gcommon.PKIidType(endpoint)
si := &gossip.StateInfo{
PkiId: pkiID,
}
......@@ -538,15 +558,15 @@ func stateInfoMsg(id int) discovery2.NetworkMember {
},
}
sm, _ := gm.NoopSign()
return discovery2.NetworkMember{
return gdisc.NetworkMember{
PKIid: pkiID,
Envelope: sm.Envelope,
}
}
func aliveMsg(id int) discovery2.NetworkMember {
func aliveMsg(id int) gdisc.NetworkMember {
endpoint := fmt.Sprintf("p%d", id)
pkiID := common2.PKIidType(endpoint)
pkiID := gcommon.PKIidType(endpoint)
am := &gossip.AliveMessage{
Membership: &gossip.Member{
PkiId: pkiID,
......@@ -559,7 +579,7 @@ func aliveMsg(id int) discovery2.NetworkMember {
},
}
sm, _ := gm.NoopSign()
return discovery2.NetworkMember{
return gdisc.NetworkMember{