-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path03-submit-channel-configupdate.js
30 lines (26 loc) · 1.27 KB
/
03-submit-channel-configupdate.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
const config = require('./config');
const Client = require('fabric-client');
const fs = require('fs-extra');
const certificate = fs.readFileSync('./local_fabric/certificate', 'utf8');
const privateKey = fs.readFileSync('./local_fabric/privateKey', 'utf8');
const fabprotos = require('fabric-protos');
(async () => {
try {
const encodedConfigUpdateEnvelope = await fs.readFile('channel-configupdate.bin');
const configUpdateEnvelope = fabprotos.common.ConfigUpdateEnvelope.decode(encodedConfigUpdateEnvelope);
const encodedConfigUpdate = configUpdateEnvelope.config_update;
const signatures = configUpdateEnvelope.signatures;
const client = new Client();
await client.setAdminSigningIdentity(privateKey, certificate, 'Org1MSP');
const orderer = client.newOrderer('grpc://localhost:17050');
const txId = client.newTransactionID(true);
const response = await client.createChannel({ name: config.channel, config: encodedConfigUpdate, txId, signatures, orderer });
if (response.status !== 'SUCCESS') {
throw new Error(response.info);
}
console.log('Submitted channel config update to ordering service');
} catch (error) {
console.error(error);
process.exit(1);
}
})();