Comments (8)
may I know more about the use case?
as channel config is "open" for everyone join this channel to get. Hence the anchor peers' information are published through channel config.
For example, org1 has 2 peers. peer1 is published to other orgs for endorsement usage as anchor peer? peer2 is not listed in the channel config.
Hence,
for org1, as org1 admin knows those two peers, is it necessary to org1 admin to have this feature?
and maybe for security reason, org1 don't want to expose peer2 to org2. Hence ... I suppose by default, there some limitations about topic discussed in this issue.
from fabric-admin-sdk.
A PeerMembershipQuery using the discovery service can return all the network organizations and their member peers.
from fabric-admin-sdk.
may I know more about the use case? as channel config is "open" for everyone join this channel to get. Hence the anchor peers' information are published through channel config. For example, org1 has 2 peers. peer1 is published to other orgs for endorsement usage as anchor peer? peer2 is not listed in the channel config. Hence, for org1, as org1 admin knows those two peers, is it necessary to org1 admin to have this feature? and maybe for security reason, org1 don't want to expose peer2 to org2. Hence ... I suppose by default, there some limitations about topic discussed in this issue.
For security reasons, it is reasonable for Org 1 not to expose its non-anchor nodes to other Org.
Org 1 should have a simple one-time acquisition method to know which of its nodes are in the same ledger, instead of querying each peer node to confirm.
from fabric-admin-sdk.
may I know more about the use case? as channel config is "open" for everyone join this channel to get. Hence the anchor peers' information are published through channel config. For example, org1 has 2 peers. peer1 is published to other orgs for endorsement usage as anchor peer? peer2 is not listed in the channel config. Hence, for org1, as org1 admin knows those two peers, is it necessary to org1 admin to have this feature? and maybe for security reason, org1 don't want to expose peer2 to org2. Hence ... I suppose by default, there some limitations about topic discussed in this issue.
For security reasons, it is reasonable for Org 1 not to expose its non-anchor nodes to other Org. Org 1 should have a simple one-time acquisition method to know which of its nodes are in the same ledger, instead of querying each peer node to confirm.
could you please try the api as @bestbeforetoday's suggestion?
from fabric-admin-sdk.
may I know more about the use case? as channel config is "open" for everyone join this channel to get. Hence the anchor peers' information are published through channel config. For example, org1 has 2 peers. peer1 is published to other orgs for endorsement usage as anchor peer? peer2 is not listed in the channel config. Hence, for org1, as org1 admin knows those two peers, is it necessary to org1 admin to have this feature? and maybe for security reason, org1 don't want to expose peer2 to org2. Hence ... I suppose by default, there some limitations about topic discussed in this issue.
For security reasons, it is reasonable for Org 1 not to expose its non-anchor nodes to other Org. Org 1 should have a simple one-time acquisition method to know which of its nodes are in the same ledger, instead of querying each peer node to confirm.
could you please try the api as @bestbeforetoday's suggestion?
yes, it worked, the result json as follows.
{
"peers_by_org":{
"CqMSP":{
"peers":[
{
"state_info":{
"payload":"GAV6bxIUCKjFnMn364myFxCUgJ/K9+uJshcaIOOqEE3pENasJBeEcKePpyd4CewXtmPPwnO0v7GwPrX4IiAuUxNhlDl6sh6uN/3g+ai/xa7gaOcSn1ebTGtxs9fBfCoTCAEaDwoKX2xpZmVjeWNsZRIBMQ==",
"signature":"MEUCIQDGQY0QL7JyAwDLn6sIfuCemdOXH6nD7ICd8X8fkjo0LgIgQkz86KFEIXa3WvbjKjlXtqqbNO3G5SgihRAQO7eEPzY="
},
"membership_info":{
"payload":"GAEqTQo9ChlwZWVyMS5jcS5leGFtcGxlLmNvbTo3MDUxGiDjqhBN6RDWrCQXhHCnj6cneAnsF7Zjz8JztL+xsD61+BIMCNrR3bXP64myFxAb",
"signature":"MEQCICQ63RER7207ig9oEf6XZOHSENuPozK1TKpUP53ahqMFAiBAoTv9WRyMKCTGDSM4AKtxIdaJ2cyLlHDVarCsuhOPZQ=="
},
"identity":"CgVDcU1TUBLNBy0tLS0tQkVHSU4gQ0VSVElGSUNBVEUtLS0tLQpNSUlDb0RDQ0FrZWdBd0lCQWdJVVlBS0Z5L2JZWlNmMWR4UGxjODROUnhIYW1OTXdDZ1lJS29aSXpqMEVBd0l3CmFERUxNQWtHQTFVRUJoTUNRMDR4RVRBUEJnTlZCQWdUQ0VKbGFTQkthVzVuTVJFd0R3WURWUVFIRXdoQ1pXa2cKU21sdVp6RVhNQlVHQTFVRUNoTU9ZM0V1WlhoaGJYQnNaUzVqYjIweEdqQVlCZ05WQkFNVEVXTmhMbU54TG1WNApZVzF3YkdVdVkyOXRNQ0FYRFRJek1EVXpNVEEyTXprd01Gb1lEekl3TnpNd05URTRNRFl6T1RBd1dqQmFNUXN3CkNRWURWUVFHRXdKRFRqRVRNQkVHQTFVRUNCTUtRMmh2Ym1jZ1VXbHVaekVYTUJVR0ExVUVDaE1PWTNFdVpYaGgKYlhCc1pTNWpiMjB4RFRBTEJnTlZCQXNUQkhCbFpYSXhEakFNQmdOVkJBTVRCWEJsWlhJeE1Ga3dFd1lIS29aSQp6ajBDQVFZSUtvWkl6ajBEQVFjRFFnQUVnSHlJclpCODY1cTg4Z0pKc3ltbCtMKzlsN3lpamRmT1BPVW92aHBCCkYwcDNRblVERWt5S0xZdVpQV283eXRYbmJiSGR4b0dUTUNSbG9HNVF1VHVtZHFPQjJqQ0IxekFPQmdOVkhROEIKQWY4RUJBTUNCNEF3REFZRFZSMFRBUUgvQkFJd0FEQWRCZ05WSFE0RUZnUVV4ek5mc3E1elYwZno3QkI0TUJYdgo2eThUKzhjd0h3WURWUjBqQkJnd0ZvQVVxMXBWeHYxeU04bWlLQzBQL3pxY0Vua3Mrcmd3SHdZRFZSMFJCQmd3CkZvSVVjR1ZsY2pFdVkzRXVaWGhoYlhCc1pTNWpiMjB3VmdZSUtnTUVCUVlIQ0FFRVNuc2lZWFIwY25NaU9uc2kKYUdZdVFXWm1hV3hwWVhScGIyNGlPaUlpTENKb1ppNUZibkp2Ykd4dFpXNTBTVVFpT2lKd1pXVnlNU0lzSW1obQpMbFI1Y0dVaU9pSndaV1Z5SW4xOU1Bb0dDQ3FHU000OUJBTUNBMGNBTUVRQ0lEbWpLM0tJOUR1S25sNlYwVStBClVweEhvV3hYWVlQbDlMNm9ER256Y3lrcEFpQUwrN0V1UG01N2NLZE5uUEZLOVRHbG4rS1BtdSsxOEwwWDhUZlgKUlZkZ2t3PT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo="
}
]
}
}
}
the peer endpoint is in membership_info's payload, the payload's proto struct is gossip.GossipMessage,
the Content of gossip.GossipMessage is *gossip.GossipMessage_AliveMsg
json result as follows
{
"AliveMsg": {
"membership": {
"endpoint": "peer0.cq.example.com:7051",
"pki_id": "k67w32SfrfzhaW7Gp/fz00gi2rh99K3HO3iOa63g17M="
},
"timestamp": {
"inc_num": 1685515440265200767,
"seq_num": 1903
}
}
}
i will give the implements code for this
from fabric-admin-sdk.
implements code as follows
package discovery
import (
"context"
"github.com/hyperledger/fabric-admin-sdk/pkg/identity"
"github.com/hyperledger/fabric-protos-go-apiv2/discovery"
"github.com/hyperledger/fabric-protos-go-apiv2/msp"
"google.golang.org/grpc"
"google.golang.org/protobuf/proto"
)
func PeerMembershipQuery(ctx context.Context, conn *grpc.ClientConn, signer identity.SigningIdentity, channel string) (*discovery.PeerMembershipResult, error) {
id := &msp.SerializedIdentity{
Mspid: signer.MspID(),
IdBytes: signer.Credentials(),
}
idBytes, err := proto.Marshal(id)
if err != nil {
return nil, err
}
querys := []*discovery.Query{
&discovery.Query{
Channel: channel,
Query: &discovery.Query_PeerQuery{
PeerQuery: &discovery.PeerMembershipQuery{
Filter: nil,
},
},
},
}
request := &discovery.Request{
Authentication: &discovery.AuthInfo{
ClientIdentity: idBytes,
ClientTlsCertHash: signer.Credentials(),
},
Queries: querys,
}
payload, err := proto.Marshal(request)
if err != nil {
return nil, err
}
sig, err := signer.Sign(payload)
if err != nil {
return nil, err
}
signedRequest := discovery.SignedRequest{
Payload: payload,
Signature: sig,
}
cli := discovery.NewDiscoveryClient(conn)
rs, err := cli.Discover(ctx, &signedRequest)
if err != nil {
return nil, err
}
for _, qrs := range rs.Results {
return qrs.GetMembers(), nil
}
return nil, nil
}
from fabric-admin-sdk.
implements code as follows
package discovery import ( "context" "github.com/hyperledger/fabric-admin-sdk/pkg/identity" "github.com/hyperledger/fabric-protos-go-apiv2/discovery" "github.com/hyperledger/fabric-protos-go-apiv2/msp" "google.golang.org/grpc" "google.golang.org/protobuf/proto" ) func PeerMembershipQuery(ctx context.Context, conn *grpc.ClientConn, signer identity.SigningIdentity, channel string) (*discovery.PeerMembershipResult, error) { id := &msp.SerializedIdentity{ Mspid: signer.MspID(), IdBytes: signer.Credentials(), } idBytes, err := proto.Marshal(id) if err != nil { return nil, err } querys := []*discovery.Query{ &discovery.Query{ Channel: channel, Query: &discovery.Query_PeerQuery{ PeerQuery: &discovery.PeerMembershipQuery{ Filter: nil, }, }, }, } request := &discovery.Request{ Authentication: &discovery.AuthInfo{ ClientIdentity: idBytes, ClientTlsCertHash: signer.Credentials(), }, Queries: querys, } payload, err := proto.Marshal(request) if err != nil { return nil, err } sig, err := signer.Sign(payload) if err != nil { return nil, err } signedRequest := discovery.SignedRequest{ Payload: payload, Signature: sig, } cli := discovery.NewDiscoveryClient(conn) rs, err := cli.Discover(ctx, &signedRequest) if err != nil { return nil, err } for _, qrs := range rs.Results { return qrs.GetMembers(), nil } return nil, nil }
could you please open a PR with your contribution?
from fabric-admin-sdk.
implements code as follows
package discovery import ( "context" "github.com/hyperledger/fabric-admin-sdk/pkg/identity" "github.com/hyperledger/fabric-protos-go-apiv2/discovery" "github.com/hyperledger/fabric-protos-go-apiv2/msp" "google.golang.org/grpc" "google.golang.org/protobuf/proto" ) func PeerMembershipQuery(ctx context.Context, conn *grpc.ClientConn, signer identity.SigningIdentity, channel string) (*discovery.PeerMembershipResult, error) { id := &msp.SerializedIdentity{ Mspid: signer.MspID(), IdBytes: signer.Credentials(), } idBytes, err := proto.Marshal(id) if err != nil { return nil, err } querys := []*discovery.Query{ &discovery.Query{ Channel: channel, Query: &discovery.Query_PeerQuery{ PeerQuery: &discovery.PeerMembershipQuery{ Filter: nil, }, }, }, } request := &discovery.Request{ Authentication: &discovery.AuthInfo{ ClientIdentity: idBytes, ClientTlsCertHash: signer.Credentials(), }, Queries: querys, } payload, err := proto.Marshal(request) if err != nil { return nil, err } sig, err := signer.Sign(payload) if err != nil { return nil, err } signedRequest := discovery.SignedRequest{ Payload: payload, Signature: sig, } cli := discovery.NewDiscoveryClient(conn) rs, err := cli.Discover(ctx, &signedRequest) if err != nil { return nil, err } for _, qrs := range rs.Results { return qrs.GetMembers(), nil } return nil, nil }
could you please open a PR with your contribution?
ok,i will do this.
from fabric-admin-sdk.
Related Issues (20)
- Avoid need for sleeps after creating channel using API HOT 9
- Chaincode package docs and examples
- Chaincode: Get installed package HOT 3
- Chaincode: Query approved definition
- to suppport channel.GetConfigBlockFromOrderer(...) HOT 2
- can't work with fabric2.5 beta HOT 29
- How to set SignaturePolicy for Collections HOT 6
- Try to enable go lint with options HOT 4
- to support list channels peer has joined HOT 10
- to support GetConfigBlockFromOrdererByNumber HOT 4
- missing attached details for chaincode.Commit(...) HOT 4
- need a function to translate SignaturePolicyEnvelope to human readable expression HOT 5
- add org.hyperledger.fabric:GetMetadata into go API HOT 2
- Test coverage HOT 4
- update CI with fabric 2.5
- Nominate channingduan as maintainer HOT 1
- TypeScript features implementation HOT 1
- CI pipeline for github release with tag
- chaincode package golang HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fabric-admin-sdk.