_flattenNpmDepsTree (npmDepsTree, npmDepMap = {}) { for (const [depName, depMetadata] of Object.entries(npmDepsTree)) { const depMetadataShortend = { version: depMetadata.version, resolved: depMetadata.resolved ? depMetadata.resolved : depMetadata.version, integrity: depMetadata.integrity, requires: depMetadata.requires } const hashedDepValues = hash(depMetadataShortend) npmDepMap[`${depName}@${depMetadata.version}-${hashedDepValues}`] = depMetadataShortend const nestedDepsTree = depMetadata.dependencies if (nestedDepsTree && Object.keys(nestedDepsTree).length !== 0) { this._flattenNpmDepsTree(nestedDepsTree, npmDepMap) } } return npmDepMap }
async.forever(function(next) { setTimeout(function() { if (that._unregisterEndPoints.size() > 0) { const serviceManager = require("../services"); serviceManager.remoteClientService().registerEndpoint(that._unregisterEndPoints, function(endPointMapping) { for (let mapping of endPointMapping.entries()) { logger.debug("endpoint-dictionary", "register endpoint[%s, %s].", mapping[0].endpointName(), mapping[1]); that._registerEndPoints.set(hash(mapping[0]), mapping[1]); } endPointMapping.forEach(function(value, key) { that._unregisterEndPoints.remove(key); }); next(); }); } else { next(); } }, 5 * 1000); }, function(err) { logger.error("endpoint-dictionary", "Failed to execute register endpoint task. Reason: %s", err.message); });
addNewBlock() { let block = { timestamp: Date.now(), transactions: this.curr_transactions, }; if(validator.proofOfWork() == TARGET_HASH){ block.hash = hash(block); this.getLastBlock((lastBlock) => { if(lastBlock){ block.prevHash = lastBlock.hash; block.index = lastBlock.index + 1; } let newBlock = blockChainModel(block); newBlock.save((err) => { if(err) return console.log(chalk.red('Cannot save Block to DB ', err.message)); console.log(chalk.green('Block Saved on the DB')); }); this.chain.push(block); this.curr_transactions = []; return block; }); } }
resolve().then(result => { const cacheKey = hash( Object.assign({scope: info.cacheControl.scope}, args, info.path) );
resolve().then(data => { const cacheKey = hash( Object.assign({scope: info.cacheControl.scope}, args, info.path) );
resolve().then(data => { const cacheKey = hash( Object.assign({scope: info.cacheControl.scope}, args, info.path) );