{"action":"opened","issue":{"url":"https://api.github.com/repos/hyperledger/composer/issues/4240","repository_url":"https://api.github.com/repos/hyperledger/composer","labels_url":"https://api.github.com/repos/hyperledger/composer/issues/4240/labels{/name}","comments_url":"https://api.github.com/repos/hyperledger/composer/issues/4240/comments","events_url":"https://api.github.com/repos/hyperledger/composer/issues/4240/events","html_url":"https://github.com/hyperledger/composer/issues/4240","id":339287095,"node_id":"MDU6SXNzdWUzMzkyODcwOTU=","number":4240,"title":"composer-connector-hlfv1/hlfconnection.js getChannelPeersInOrg bug","user":{"login":"ozt88","id":6870134,"node_id":"MDQ6VXNlcjY4NzAxMzQ=","avatar_url":"https://avatars3.githubusercontent.com/u/6870134?v=4","gravatar_id":"","url":"https://api.github.com/users/ozt88","html_url":"https://github.com/ozt88","followers_url":"https://api.github.com/users/ozt88/followers","following_url":"https://api.github.com/users/ozt88/following{/other_user}","gists_url":"https://api.github.com/users/ozt88/gists{/gist_id}","starred_url":"https://api.github.com/users/ozt88/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ozt88/subscriptions","organizations_url":"https://api.github.com/users/ozt88/orgs","repos_url":"https://api.github.com/users/ozt88/repos","events_url":"https://api.github.com/users/ozt88/events{/privacy}","received_events_url":"https://api.github.com/users/ozt88/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-07-09T02:42:55Z","updated_at":"2018-07-09T02:42:55Z","closed_at":null,"author_association":"NONE","body":"<!--- Provide a general summary of the issue in the Title above -->\r\n\r\n## Context\r\n<!--- Provide a more detailed introduction to the issue itself, and why you consider it to be a bug -->\r\n``` javascript\r\n/// composer-connector-hlfv1/hlfconnection.js (line 1203~)\r\ngetChannelPeersInOrg(peerRoles) {\r\n    let peers = this.client.getPeersForOrgOnChannel(this.channel.getName());\r\n    return peers.filter((cPeer) => {\r\n        return peerRoles.every((peerRole) => {\r\n            return cPeer.isInRole(peerRole);\r\n        });\r\n    });\r\n}\r\n```\r\n\r\n## Expected Behavior\r\n<!--- Tell us what should happen -->\r\nreturn peers with role information\r\n\r\n## Actual Behavior\r\n<!--- Tell us what happens instead -->\r\nreturn peers without role information\r\n\r\n## Possible Fix\r\n<!--- Not obligatory, but suggest a fix or reason for the bug -->\r\n``` javascript\r\n/// fabric-client/lib/Client.js getPeersForOrgOnChannel :line 1825~\r\nif(org_peer.getName() === channel_peer.getName()) {\r\n    found_peers[org_peer.getName()] = org_peer;//to avoid Duplicate Peers\r\n    logger.debug('%s - adding peer to list:%s',method,org_peer.getName());\r\n}\r\n```\r\nthis accumulates org_peers to return, but org_peer doen't have role information.\r\n``` javascript\r\nif(org_peer.getName() === channel_peer.getName()) {\r\n    found_peers[org_peer.getName()] = channel_peer; //to avoid Duplicate Peers\r\n    logger.debug('%s - adding peer to list:%s',method,org_peer.getName());\r\n}\r\n```\r\nchannel_peer has role information and compatibility with org_peer.\r\nI already made an [issue on fabric jira](https://jira.hyperledger.org/browse/FAB-11071)\r\nbut they didn't listen, you can do better than me.\r\n\r\n## Steps to Reproduce\r\n<!--- Provide a link to a live example, or an unambiguous set of steps to -->\r\n<!--- reproduce this bug include code to reproduce, if relevant -->\r\n1. call this function with proper connection\r\n\r\n## Existing issues\r\n<!-- Have you searched for any existing issues or are their any similar issues that you've found? -->\r\n- [ ] [Stack Overflow issues](http://stackoverflow.com/tags/hyperledger-composer)\r\n- [ ] [GitHub Issues](https://github.com/hyperledger/composer/issues)\r\n- [ ] [Rocket Chat history](https://chat.hyperledger.org/channel/composer)\r\n\r\n<!-- please include any links to issues here -->\r\n\r\n## Context\r\n<!--- How has this bug affected you? What were you trying to accomplish? -->\r\n``` javascript\r\n/// composer-connector-hlfv1/hlfqueryhandler.js (line 38~)\r\nconstructor(connection) {\r\n    const method = 'constructor';\r\n    LOG.entry(method);\r\n    this.allQueryPeers = connection.getChannelPeersInOrg([FABRIC_CONSTANTS.NetworkConfig.CHAINCODE_QUERY_ROLE]);\r\n    this.queryPeerIndex = -1;\r\n\r\n    this.connection = connection;\r\n    LOG.exit(method);\r\n}\r\n```\r\nHLFQueryHandler constructed with allQueryPeers from getChannelPeersInOrg.\r\nBut the peers doens't have any role information.\r\n```javascript\r\n//fabric-client/lib/Peer.js :line 84~\r\nisInRole(role) {\r\n\tif(!role) {\r\n\t\treturn true;\r\n\t} else if(typeof this._roles[role] === 'undefined') {\r\n\t\treturn true;\r\n\t} else {\r\n\t\treturn this._roles[role];\r\n\t}\r\n}\r\n```\r\nPeer.isInrole is always true.\r\nThis HLFQueryHandler can't tell the real CHAINCODE_QUERY_ROLE peers.\r\nSo every card's connectionProfile for query doesn't work\r\n\r\n## Your Environment\r\n<!--- Include as many relevant details about the environment you experienced the bug in -->\r\n* Version used: composer-connector-hlfv1 v0.19.13\r\n* Environment name and version (e.g. Chrome 39, node.js 5.4):\r\n* Operating System and version (desktop or mobile):\r\n* Link to your project:\r\n"}}
{"actor":{"display_login":"ozt88"}}