-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathinvoke.js
49 lines (38 loc) · 1.73 KB
/
invoke.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const Client = require('fabric-client');
const myClient = require('./index.js');
var await = require('await')
const fs = require('fs');
const path = require('path');
const org1 = 'org1';
const org2 = 'org2';
const org3 = 'org3';
const ORG1_ADMIN_MSP = './crypto-config/peerOrganizations/org1.ksachdeva-exp.com/users/[email protected]/msp';
const ORG2_ADMIN_MSP = './crypto-config/peerOrganizations/org2.ksachdeva-exp.com/users/[email protected]/msp';
const ORG3_ADMIN_MSP = './crypto-config/peerOrganizations/org3.ksachdeva-exp.com/users/[email protected]/msp';
const ORG1_MSP_ID = 'Org1MSP'
const ORG2_MSP_ID = 'Org2MSP'
const ORG3_MSP_ID = 'Org3MSP'
const CHANNEL_NAME = 'ksachdeva-exp-channel-1'
const CHAIN_CODE_ID = 'ksachdeva-exp-cc'
async function queryChaincode(orgn, adminmsp, mspid) {
const client = await getClient(orgn, adminmsp, mspid);
const channel = await getChannel(client, orgn);
console.log(`Quering the Chaincode on the peers of ${org} ..`);
const response = await channel.queryByChaincode({
chaincodeId: config.CHAIN_CODE_ID,
fcn: 'query',
args: ["a"],
txId: client.newTransactionID()
});
console.log(`Peer0 of ${org} has ${response[0].toString('utf8')} as the current value for 'a'..`);
console.log(`Peer1 of ${org} has ${response[1].toString('utf8')} as the current value for 'a'..`);
}
async function main() {
console.log('############ ORG1 ###################');
await queryChaincode(Organization.ORG1);
console.log('############ ORG2 ###################');
await queryChaincode(Organization.ORG2);
console.log('############ ORG3 ###################');
await queryChaincode(Organization.ORG3);
}
main();