Skip to content

Commit

Permalink
BE-750 Implement queryInstantiatedChaincodes by using "getchaincodes"…
Browse files Browse the repository at this point in the history
… func on LSCC (#115)

Signed-off-by: jeeva <jeevasang@gmail.com>
  • Loading branch information
JeevaSang authored Jun 8, 2020
1 parent 743d3c0 commit 9412cda
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 8 additions & 0 deletions app/platform/fabric/gateway/FabricGateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,14 @@ class FabricGateway {
}
}

async queryInstantiatedChaincodes() {
const network = await this.gateway.getNetwork(this.defaultChannelName);
const contract = network.getContract('lscc');
const result = await contract.evaluateTransaction('GetChaincodes');
const resultJson = fabprotos.protos.ChaincodeQueryResponse.decode(result);
return resultJson;
}

getPeer_pem(pemPath) {
const data = fs.readFileSync(path.resolve(__dirname, '../../../..', pemPath));
const pem = Buffer.from(data).toString();
Expand Down
7 changes: 1 addition & 6 deletions app/platform/fabric/sync/SyncService.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ class SyncServices {
// Insert chaincode
await this.insertNewChannelChaincode(
client,
channel,
channel_genesis_hash,
discoveryResults
);
Expand Down Expand Up @@ -298,15 +297,11 @@ class SyncServices {
*/
async insertNewChannelChaincode(
client,
channel,
channel_genesis_hash,
discoveryResults
) {
const network_name = client.network_name;
const chaincodes = await channel.queryInstantiatedChaincodes(
client.getDefaultPeer(),
true
);
const chaincodes = await client.fabricGateway.queryInstantiatedChaincodes();
for (const chaincode of chaincodes.chaincodes) {
const chaincode_row = {
name: chaincode.name,
Expand Down

0 comments on commit 9412cda

Please sign in to comment.