代码拉取完成,页面将自动刷新
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package nwo
import (
"encoding/json"
"path/filepath"
"github.com/hyperledger/fabric/integration/nwo/commands"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
)
// DiscoveredPeer defines a struct for discovering peers using discovery service.
// each peer in the result will have these fields
type DiscoveredPeer struct {
MSPID string `yaml:"mspid,omitempty"`
Endpoint string `yaml:"endpoint,omitempty"`
Identity string `yaml:"identity,omitempty"`
Chaincodes []string `yaml:"chaincodes,omitempty"`
}
// running discovery service command discover peers against peer using channel name and user as specified in the
// function arguments. return a slice of the discovered peers
func DiscoverPeers(n *Network, p *Peer, user, channelName string) func() []DiscoveredPeer {
return func() []DiscoveredPeer {
peers := commands.Peers{
UserCert: n.PeerUserCert(p, user),
UserKey: n.PeerUserKey(p, user),
MSPID: n.Organization(p.Organization).MSPID,
Server: n.PeerAddress(p, ListenPort),
Channel: channelName,
}
if n.ClientAuthRequired {
peers.ClientCert = filepath.Join(n.PeerUserTLSDir(p, user), "client.crt")
peers.ClientKey = filepath.Join(n.PeerUserTLSDir(p, user), "client.key")
}
sess, err := n.Discover(peers)
Expect(err).NotTo(HaveOccurred())
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
var discovered []DiscoveredPeer
err = json.Unmarshal(sess.Out.Contents(), &discovered)
Expect(err).NotTo(HaveOccurred())
return discovered
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。