Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (CaliperUtils.checkProperty(cc, 'targetPeers')) {
return new Set(cc.targetPeers);
}
// we need to gather the target peers from the channel's peer section
// based on their provided functionality (endorsing and cc query)
let results = new Set();
let peers = this.network.channels[channel].peers;
for (let key in peers) {
if (!peers.hasOwnProperty(key)) {
continue;
}
let peer = peers[key];
// if only the peer name is present in the config, then it is a target based on the default values
if (!CaliperUtils.checkDefined(peer)) {
results.add(key.toString());
}
// the default value of 'endorsingPeer' is true, or it's explicitly set to true
if (!CaliperUtils.checkProperty(peer, 'endorsingPeer') ||
(CaliperUtils.checkProperty(peer, 'endorsingPeer') && peer.endorsingPeer)) {
results.add(key.toString());
continue;
}
// the default value of 'chaincodeQuery' is true, or it's explicitly set to true
if (!CaliperUtils.checkProperty(peer, 'chaincodeQuery') ||
(CaliperUtils.checkProperty(peer, 'chaincodeQuery') && peer.chaincodeQuery)) {
results.add(key.toString());
}
}