diff --git a/server/web3bcspider/blockchain.js b/server/web3bcspider/blockchain.js index 4dca630..fa0ffb4 100644 --- a/server/web3bcspider/blockchain.js +++ b/server/web3bcspider/blockchain.js @@ -33,6 +33,7 @@ class BlockChain { async init() { this.web3Conf = metaFactory.getWeb3Conf(this.netId); + console.log(this.web3Conf); this.contractsConf = metaFactory.getContractsConf(this.netId); this.netDir = metaFactory.getNetDir(this.netId); diff --git a/server/web3bcspider/metadata/factory.js b/server/web3bcspider/metadata/factory.js index 76c9494..ef9fcd8 100644 --- a/server/web3bcspider/metadata/factory.js +++ b/server/web3bcspider/metadata/factory.js @@ -157,28 +157,29 @@ function traverseMetaList(name, cb) { } } -function getWeb3Conf(netId) { +function getConf(netId) { const keys = Object.keys(web3ConfHash); for (let i = 0; i < keys.length; ++i) { - if (keys[i] == netId) { - return web3ConfHash[keys[i]]['Web3']; + const conf = web3ConfHash[keys[i]]; + if (conf['net_id'] == netId) { + return conf; } } return null; } +function getWeb3Conf(netId) { + const conf = getConf(netId); + return conf ? conf['Web3'] : null; +} + function getWeb3BcSpiderConf() { return web3BcSpiderConf; } function getContractsConf(netId) { - const keys = Object.keys(web3ConfHash); - for (let i = 0; i < keys.length; ++i) { - if (keys[i] == netId) { - return web3ConfHash[keys[i]]['Contract']; - } - } - return null; + const conf = getConf(netId); + return conf ? conf['Contract'] : null; } function getNetList() {