Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(networkConfig, workspace_root) {
super(networkConfig);
this.bcType = 'fabric';
this.workspaceRoot = workspace_root;
this.version = new Version(require('fabric-client/package').version);
this.network = undefined;
if (typeof networkConfig === 'string') {
let configPath = CaliperUtils.resolvePath(networkConfig, workspace_root);
this.network = CaliperUtils.parseYaml(configPath);
} else if (typeof networkConfig === 'object' && networkConfig !== null) {
// clone the object to prevent modification by other objects
this.network = CaliperUtils.parseYamlString(CaliperUtils.stringifyYaml(networkConfig));
} else {
throw new Error('[FabricNetwork.constructor] Parameter \'networkConfig\' is neither a file path nor an object');
}
this.clientProfiles = new Map();
this.adminProfiles = new Map();
this.registrarProfiles = new Map();
this.eventSources = [];
this.clientIndex = 0;
this.txIndex = -1;
this.randomTargetPeerCache = new Map();
this.channelEventSourcesCache = new Map();
this.randomTargetOrdererCache = new Map();
this.wallet = undefined;
this.userContracts = new Map();
constructor(networkConfig, workspace_root) {
CaliperUtils.assertDefined(networkConfig, '[FabricNetwork.constructor] Parameter \'networkConfig\' if undefined or null');
this.network = undefined;
if (typeof networkConfig === 'string') {
let configPath = CaliperUtils.resolvePath(networkConfig, workspace_root);
this.network = CaliperUtils.parseYaml(configPath);
} else if (typeof networkConfig === 'object' && networkConfig !== null) {
// clone the object to prevent modification by other objects
this.network = CaliperUtils.parseYamlString(CaliperUtils.stringifyYaml(networkConfig));
} else {
throw new Error('[FabricNetwork.constructor] Parameter \'networkConfig\' is neither a file path nor an object');
}
this.clientConfigs = {};
this.compatibilityMode = false; // if event URLs are detected for the peers, we're using Fabric 1.0
this.tls = false;
this.mutualTls = false;
this.contractMapping = new Map();
this._processConfiguration(workspace_root);
}
getNewNetworkObject() {
return CaliperUtils.parseYamlString(CaliperUtils.stringifyYaml(this.network));
}