refactor networks
This commit is contained in:
parent
fb591b39c1
commit
e25ffde6db
|
@ -26,7 +26,7 @@ Network.prototype.toString = function toString() {
|
|||
* @param {string|Array} keys - if set, only check if the magic number associated with this name matches
|
||||
* @return Network
|
||||
*/
|
||||
function getNetwork(arg, keys) {
|
||||
function get(arg, keys) {
|
||||
if (~networks.indexOf(arg)) {
|
||||
return arg;
|
||||
}
|
||||
|
@ -34,8 +34,11 @@ function getNetwork(arg, keys) {
|
|||
if (!_.isArray(keys)) {
|
||||
keys = [keys];
|
||||
}
|
||||
var containsArg = function(key) {
|
||||
return networks[index][key] === arg;
|
||||
};
|
||||
for (var index in networks) {
|
||||
if (_.any(keys, function(key) { return networks[index][key] === arg; })) {
|
||||
if (_.any(keys, containsArg)) {
|
||||
return networks[index];
|
||||
}
|
||||
}
|
||||
|
@ -151,13 +154,13 @@ addNetwork({
|
|||
* @instance
|
||||
* @member Networks#livenet
|
||||
*/
|
||||
var livenet = getNetwork('livenet');
|
||||
var livenet = get('livenet');
|
||||
|
||||
/**
|
||||
* @instance
|
||||
* @member Networks#testnet
|
||||
*/
|
||||
var testnet = getNetwork('testnet');
|
||||
var testnet = get('testnet');
|
||||
|
||||
/**
|
||||
* @namespace Networks
|
||||
|
@ -169,5 +172,5 @@ module.exports = {
|
|||
livenet: livenet,
|
||||
mainnet: livenet,
|
||||
testnet: testnet,
|
||||
get: getNetwork
|
||||
get: get
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue