Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE-741] Remove fullpath option with function #101

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions TROUBLESHOOT.md
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,6 @@ adminPrivateKeyPath /Users/USER_ID/workspace/fabric-1.3/fabric-samples/balance-
organizations:
{ Org1MSP:
{ mspid: 'Org1MSP',
fullpath: true,
adminPrivateKey: [Object],
signedCert: [Object] } },
peers:
Expand Down Expand Up @@ -901,7 +900,6 @@ adminPrivateKeyPath /Users/USER_ID/workspace/fabric-1.3/fabric-samples/balance-
organizations:
{ Org1MSP:
{ mspid: 'Org1MSP',
fullpath: true,
adminPrivateKey: [Object],
signedCert: [Object] } },
peers:
Expand Down
10 changes: 1 addition & 9 deletions app/platform/fabric/Platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,7 @@ class Platform {

// Setting organization enrolment files
logger.debug('Setting admin organization enrolment files');
try {
this.network_configs = await FabricUtils.setAdminEnrolmentPath(
network_configs
);
} catch (e) {
logger.error(e);
clientstatus = false;
this.network_configs = network_configs;
}
this.network_configs = network_configs;

for (const network_name in this.network_configs) {
// this.networks.set(network_name, new Map());
Expand Down
1 change: 0 additions & 1 deletion app/platform/fabric/connection-profile/first-network.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"organizations": {
"Org1MSP": {
"mspid": "Org1MSP",
"fullpath": true,
"adminPrivateKey": {
"path": "/fabric-path/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/1bebc656f198efb4b5bed08ef42cf3b2d89ac86f0a6b928e7a172fd823df0a48_sk"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"organizations": {
"org1": {
"mspid": "Org1ExampleCom",
"fullpath": true,
"adminPrivateKey": {
"path": "./app/platform/fabric/e2e-test/specs/crypto-config/peerOrganizations/org1/users/Admin@org1/msp/keystore/priv_sk"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"organizations": {
"org2": {
"mspid": "Org2ExampleCom",
"fullpath": true,
"adminPrivateKey": {
"path": "./app/platform/fabric/e2e-test/specs/crypto-config/peerOrganizations/org2/users/Admin@org2/msp/keystore/priv_sk"
},
Expand Down
4 changes: 1 addition & 3 deletions app/platform/fabric/sync/SyncPlatform.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ class SyncPlatform {
global.hfc.config.set('discovery-cache-life', this.blocksSyncTime);
global.hfc.config.set('initialize-with-discovery', true);

const client_configs = network_configs[this.network_name];

this.client_configs = await FabricUtils.setOrgEnrolmentPath(client_configs);
this.client_configs = network_configs[this.network_name];

this.client = await FabricUtils.createFabricClient(
this.client_configs,
Expand Down
71 changes: 0 additions & 71 deletions app/platform/fabric/utils/FabricUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,75 +95,6 @@ function processTLS_URL(client_config) {
return client_config;
}

/**
*
*
* @param {*} network_configs
* @returns
*/
async function setAdminEnrolmentPath(network_configs) {
for (const network_name in network_configs) {
network_configs[network_name] = setOrgEnrolmentPath(
network_configs[network_name]
);
}
return network_configs;
}

/**
*
*
* @param {*} network_config
* @returns
*/
function setOrgEnrolmentPath(network_config) {
if (network_config && network_config.organizations) {
for (const organization_name in network_config.organizations) {
/*
* Checking files path is defined as full path or directory
* If directory, then it will consider the first file
*/
const organization = network_config.organizations[organization_name];
if (!organization.fullpath) {
// Setting admin private key as first file from keystore dir
logger.debug(
'Organization [%s] enrolment files path defined as directory',
organization_name
);
if (organization.adminPrivateKey) {
const privateKeyPath = organization.adminPrivateKey.path;
try {
const files = fs.readdirSync(privateKeyPath);
if (files && files.length > 0) {
organization.adminPrivateKey.path = path.join(privateKeyPath, files[0]);
}
} catch (err) {
logger.error(err);
}
}
// Setting admin private key as first file from signcerts dir
if (organization.signedCert) {
const signedCertPath = organization.signedCert.path;
try {
const files = fs.readdirSync(signedCertPath);
if (files && files.length > 0) {
organization.signedCert.path = path.join(signedCertPath, files[0]);
}
} catch (err) {
logger.error(err);
}
}
} else {
logger.debug(
'Organization [%s] enrolment files path defined as full path',
organization_name
);
}
}
}
return network_config;
}

/**
*
*
Expand Down Expand Up @@ -259,8 +190,6 @@ function readFileSync(config_path) {
}
}

exports.setAdminEnrolmentPath = setAdminEnrolmentPath;
exports.setOrgEnrolmentPath = setOrgEnrolmentPath;
exports.generateBlockHash = generateBlockHash;
exports.createFabricClient = createFabricClient;
exports.getBlockTimeStamp = getBlockTimeStamp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"organizations": {
"org1": {
"mspid": "Org1ExampleCom",
"fullpath": true,
"adminPrivateKey": {
"path": "GOPATH/src/github.com/hyperledger/fabric-test/tools/operator/crypto-config/peerOrganizations/org1/users/Admin@org1/msp/keystore/priv_sk"
},
Expand Down
2 changes: 0 additions & 2 deletions examples/net1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ A complete configuration **example** file is shown below for 2 ORG Blockchain in
"organizations": {
"Org1MSP": {
"mspid": "Org1MSP",
"fullpath": false,
"adminPrivateKey": {
"path":
"/tmp/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore"
Expand Down Expand Up @@ -237,7 +236,6 @@ Note: Make sure you put the right node IPs, ports and certs paths before running
"organizations": {
"Org1MSP": {
"mspid": "Org1MSP",
"fullpath": false,
"adminPrivateKey": {
"path":
"/tmp/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore"
Expand Down
1 change: 0 additions & 1 deletion examples/net1/connection-profile/first-network.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"organizations": {
"Org1MSP": {
"mspid": "Org1MSP",
"fullpath": true,
"adminPrivateKey": {
"path": "/tmp/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/d30992c2b7799bc5c65bf6e4839369c7dd3edf0b786eecd4a9d3a3b207d8863f_sk"
},
Expand Down