refactor: env.
This commit is contained in:
parent
3b17b8e775
commit
177272a2c5
@ -92,7 +92,6 @@ var global = utils.global;
|
|||||||
* @property {Function} address - {@link Address} constructor.
|
* @property {Function} address - {@link Address} constructor.
|
||||||
* @property {Function} wallet - {@link Wallet} constructor.
|
* @property {Function} wallet - {@link Wallet} constructor.
|
||||||
* @property {Function} walletdb - {@link WalletDB} constructor.
|
* @property {Function} walletdb - {@link WalletDB} constructor.
|
||||||
* @property {Function} provider - {@link Provider} constructor.
|
|
||||||
* @property {Function} peer - {@link Peer} constructor.
|
* @property {Function} peer - {@link Peer} constructor.
|
||||||
* @property {Function} pool - {@link Pool} constructor.
|
* @property {Function} pool - {@link Pool} constructor.
|
||||||
* @property {Function} miner - {@link Miner} constructor.
|
* @property {Function} miner - {@link Miner} constructor.
|
||||||
@ -100,7 +99,6 @@ var global = utils.global;
|
|||||||
* @property {Object} http
|
* @property {Object} http
|
||||||
* @property {Function} http.client - {@link HTTPClient} constructor.
|
* @property {Function} http.client - {@link HTTPClient} constructor.
|
||||||
* @property {Function} http.http - {@link HTTPBase} constructor.
|
* @property {Function} http.http - {@link HTTPBase} constructor.
|
||||||
* @property {Function} http.provider - {@link HTTPProvider} constructor.
|
|
||||||
* @property {Function} http.request - See {@link request}.
|
* @property {Function} http.request - See {@link request}.
|
||||||
* @property {Function} http.server - {@link HTTPServer} constructor.
|
* @property {Function} http.server - {@link HTTPServer} constructor.
|
||||||
* @property {Object} workers - See {@link module:workers}.
|
* @property {Object} workers - See {@link module:workers}.
|
||||||
@ -111,26 +109,35 @@ var global = utils.global;
|
|||||||
function Environment() {
|
function Environment() {
|
||||||
this.env = Environment;
|
this.env = Environment;
|
||||||
this.bn = require('bn.js');
|
this.bn = require('bn.js');
|
||||||
|
|
||||||
|
// Protocol
|
||||||
|
this.constants = require('./protocol/constants');
|
||||||
|
this.networks = require('./protocol/networks');
|
||||||
|
this.network = require('./protocol/network');
|
||||||
|
|
||||||
|
// Utils
|
||||||
this.utils = require('./utils/utils');
|
this.utils = require('./utils/utils');
|
||||||
this.locker = require('./utils/locker');
|
this.locker = require('./utils/locker');
|
||||||
this.reader = require('./utils/reader');
|
this.reader = require('./utils/reader');
|
||||||
this.writer = require('./utils/writer');
|
this.writer = require('./utils/writer');
|
||||||
this.ec = require('./crypto/ec');
|
|
||||||
this.lru = require('./utils/lru');
|
this.lru = require('./utils/lru');
|
||||||
this.bloom = require('./primitives/bloom');
|
|
||||||
this.rbt = require('./db/rbt');
|
|
||||||
this.lowlevelup = require('./db/lowlevelup');
|
|
||||||
this.uri = require('./utils/uri');
|
this.uri = require('./utils/uri');
|
||||||
this.logger = require('./node/logger');
|
|
||||||
this.config = require('./node/config');
|
|
||||||
|
|
||||||
this.constants = require('./protocol/constants');
|
|
||||||
this.networks = require('./protocol/networks');
|
|
||||||
this.packets = require('./net/packets');
|
|
||||||
this.network = require('./protocol/network');
|
|
||||||
this.errors = require('./utils/errors');
|
this.errors = require('./utils/errors');
|
||||||
|
|
||||||
|
// Crypto
|
||||||
|
this.ec = require('./crypto/ec');
|
||||||
|
this.crypto = require('./crypto/crypto');
|
||||||
|
this.chachapoly = require('./crypto/chachapoly');
|
||||||
|
this.scrypt = require('./crypto/scrypt');
|
||||||
|
this.siphash = require('./crypto/siphash');
|
||||||
|
|
||||||
|
// DB
|
||||||
|
this.lowlevelup = require('./db/lowlevelup');
|
||||||
this.ldb = require('./db/ldb');
|
this.ldb = require('./db/ldb');
|
||||||
this.timedata = require('./net/timedata');
|
this.rbt = require('./db/rbt');
|
||||||
|
|
||||||
|
// Primitives
|
||||||
|
this.bloom = require('./primitives/bloom');
|
||||||
this.script = require('./primitives/script');
|
this.script = require('./primitives/script');
|
||||||
this.opcode = this.script.Opcode;
|
this.opcode = this.script.Opcode;
|
||||||
this.stack = this.script.Stack;
|
this.stack = this.script.Stack;
|
||||||
@ -140,50 +147,76 @@ function Environment() {
|
|||||||
this.outpoint = this.input.Outpoint;
|
this.outpoint = this.input.Outpoint;
|
||||||
this.output = require('./primitives/output');
|
this.output = require('./primitives/output');
|
||||||
this.coin = require('./primitives/coin');
|
this.coin = require('./primitives/coin');
|
||||||
this.coins = require('./chain/coins');
|
|
||||||
this.coinview = require('./chain/coinview');
|
|
||||||
this.tx = require('./primitives/tx');
|
this.tx = require('./primitives/tx');
|
||||||
this.mtx = require('./primitives/mtx');
|
this.mtx = require('./primitives/mtx');
|
||||||
this.txdb = require('./wallet/txdb');
|
|
||||||
this.abstractblock = require('./primitives/abstractblock');
|
this.abstractblock = require('./primitives/abstractblock');
|
||||||
this.bip151 = require('./net/bip151');
|
|
||||||
this.bip150 = require('./net/bip150');
|
|
||||||
this.bip152 = require('./net/bip152');
|
|
||||||
this.memblock = require('./primitives/memblock');
|
this.memblock = require('./primitives/memblock');
|
||||||
this.block = require('./primitives/block');
|
this.block = require('./primitives/block');
|
||||||
this.merkleblock = require('./primitives/merkleblock');
|
this.merkleblock = require('./primitives/merkleblock');
|
||||||
this.headers = require('./primitives/headers');
|
this.headers = require('./primitives/headers');
|
||||||
this.fees = require('./mempool/fees');
|
this.keyring = require('./primitives/keyring');
|
||||||
|
this.hd = require('./primitives/hd');
|
||||||
|
|
||||||
|
// Node
|
||||||
|
this.logger = require('./node/logger');
|
||||||
|
this.config = require('./node/config');
|
||||||
this.node = require('./node/node');
|
this.node = require('./node/node');
|
||||||
this.spvnode = require('./node/spvnode');
|
this.spvnode = require('./node/spvnode');
|
||||||
this.fullnode = require('./node/fullnode');
|
this.fullnode = require('./node/fullnode');
|
||||||
|
|
||||||
|
// Net
|
||||||
|
this.timedata = require('./net/timedata');
|
||||||
|
this.packets = require('./net/packets');
|
||||||
|
this.invitem = this.packets.InvItem;
|
||||||
|
this.bip150 = require('./net/bip150');
|
||||||
|
this.bip151 = require('./net/bip151');
|
||||||
|
this.bip152 = require('./net/bip152');
|
||||||
|
this.peer = require('./net/peer');
|
||||||
|
this.pool = require('./net/pool');
|
||||||
|
|
||||||
|
// Chain
|
||||||
|
this.coins = require('./chain/coins');
|
||||||
|
this.coinview = require('./chain/coinview');
|
||||||
this.chainentry = require('./chain/chainentry');
|
this.chainentry = require('./chain/chainentry');
|
||||||
this.chaindb = require('./chain/chaindb');
|
this.chaindb = require('./chain/chaindb');
|
||||||
this.chain = require('./chain/chain');
|
this.chain = require('./chain/chain');
|
||||||
|
|
||||||
|
// Mempool
|
||||||
|
this.fees = require('./mempool/fees');
|
||||||
this.mempool = require('./mempool/mempool');
|
this.mempool = require('./mempool/mempool');
|
||||||
this.mempoolentry = this.mempool.MempoolEntry;
|
this.mempoolentry = this.mempool.MempoolEntry;
|
||||||
this.keyring = require('./primitives/keyring');
|
|
||||||
this.hd = require('./primitives/hd');
|
// Miner
|
||||||
|
this.miner = require('./miner/miner');
|
||||||
|
this.minerblock = require('./miner/minerblock');
|
||||||
|
|
||||||
|
// Wallet
|
||||||
|
this.txdb = require('./wallet/txdb');
|
||||||
this.wallet = require('./wallet/wallet');
|
this.wallet = require('./wallet/wallet');
|
||||||
this.account = this.wallet.Account;
|
this.account = this.wallet.Account;
|
||||||
this.walletdb = require('./wallet/walletdb');
|
this.walletdb = require('./wallet/walletdb');
|
||||||
this.path = this.walletdb.Path;
|
this.path = this.walletdb.Path;
|
||||||
this.peer = require('./net/peer');
|
|
||||||
this.pool = require('./net/pool');
|
// HTTP
|
||||||
this.miner = require('./miner/miner');
|
|
||||||
this.minerblock = this.miner.MinerBlock;
|
|
||||||
this.http = require('./http');
|
this.http = require('./http');
|
||||||
|
|
||||||
|
// Workers
|
||||||
this.workers = require('./workers/workers');
|
this.workers = require('./workers/workers');
|
||||||
|
|
||||||
|
// Sigcache
|
||||||
this.sc = require('./sigcache');
|
this.sc = require('./sigcache');
|
||||||
|
|
||||||
|
// Global Instances
|
||||||
this.sigcache = new this.sc(0);
|
this.sigcache = new this.sc(0);
|
||||||
this.time = new this.timedata();
|
this.time = new this.timedata();
|
||||||
this.defaultLogger = new this.logger('none');
|
this.defaultLogger = new this.logger('none');
|
||||||
this.workerPool = new this.workers();
|
this.workerPool = new this.workers();
|
||||||
|
|
||||||
|
// Global Worker Properties
|
||||||
this.useWorkers = false;
|
this.useWorkers = false;
|
||||||
this.master = null;
|
this.master = null;
|
||||||
|
|
||||||
|
// Initialize the environment.
|
||||||
this.set({
|
this.set({
|
||||||
network: process.env.BCOIN_NETWORK || 'main',
|
network: process.env.BCOIN_NETWORK || 'main',
|
||||||
useWorkers: +process.env.BCOIN_USE_WORKERS === 1,
|
useWorkers: +process.env.BCOIN_USE_WORKERS === 1,
|
||||||
|
|||||||
@ -11,7 +11,6 @@ var bcoin = require('../env');
|
|||||||
var constants = bcoin.constants;
|
var constants = bcoin.constants;
|
||||||
var utils = bcoin.utils;
|
var utils = bcoin.utils;
|
||||||
var assert = utils.assert;
|
var assert = utils.assert;
|
||||||
var InvItem = bcoin.packets.InvItem;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The class which all block-like objects inherit from.
|
* The class which all block-like objects inherit from.
|
||||||
@ -241,7 +240,7 @@ AbstractBlock.prototype.__defineGetter__('rhash', function() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
AbstractBlock.prototype.toInv = function toInv() {
|
AbstractBlock.prototype.toInv = function toInv() {
|
||||||
return new InvItem(constants.inv.BLOCK, this.hash('hex'));
|
return new bcoin.invitem(constants.inv.BLOCK, this.hash('hex'));
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -14,7 +14,6 @@ var constants = bcoin.constants;
|
|||||||
var Script = bcoin.script;
|
var Script = bcoin.script;
|
||||||
var Stack = bcoin.stack;
|
var Stack = bcoin.stack;
|
||||||
var BufferWriter = require('../utils/writer');
|
var BufferWriter = require('../utils/writer');
|
||||||
var InvItem = bcoin.packets.InvItem;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A static transaction object.
|
* A static transaction object.
|
||||||
@ -1757,7 +1756,7 @@ TX.prototype.__defineGetter__('wtxid', function() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
TX.prototype.toInv = function toInv() {
|
TX.prototype.toInv = function toInv() {
|
||||||
return new InvItem(constants.inv.TX, this.hash('hex'));
|
return new bcoin.invitem(constants.inv.TX, this.hash('hex'));
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user