Skip to content

Commit

Permalink
[BE-741] Remove fullpath option with function (#101)
Browse files Browse the repository at this point in the history
* Remove unused function

The `network_config` comming into `setAminEnrolmentPath` and
`setEnrolmentPath` are not used beacuse they do not actually
have `organizations`.

Signed-off-by: Sol Kang <pdpxpd@gmail.com>
Signed-off-by: 5pecia1 <pdpxpd@gmail.com>

* Remove all fullpaths

Signed-off-by: Sol Kang <pdpxpd@gmail.com>
Signed-off-by: 5pecia1 <pdpxpd@gmail.com>
  • Loading branch information
5pecia1 authored Apr 21, 2020
1 parent 855689b commit b6fb32d
Show file tree
Hide file tree
Showing 10 changed files with 2 additions and 92 deletions.
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

0 comments on commit b6fb32d

Please sign in to comment.