Skip to content

Commit

Permalink
node/browser: fix browser build.
Browse files Browse the repository at this point in the history
  • Loading branch information
chjj committed Jul 17, 2017
1 parent 10b73f6 commit db0567f
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 27 deletions.
9 changes: 2 additions & 7 deletions browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,6 @@ function formatWallet(wallet) {
});
}

bcoin.workerpool.enable();

node = new bcoin.fullnode({
hash: true,
query: true,
Expand All @@ -236,14 +234,11 @@ node = new bcoin.fullnode({
db: 'leveldb',
coinCache: 30000000,
logConsole: true,
workers: true,
logger: logger
});

wdb = node.use(bcoin.walletplugin);

node.on('error', function(err) {
;
});
wdb = node.use(bcoin.wallet.plugin);

node.chain.on('block', addItem);
node.mempool.on('tx', addItem);
Expand Down
17 changes: 8 additions & 9 deletions browser/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,29 @@
const HTTPBase = require('../lib/http/base');
const WSProxy = require('./wsproxy');
const fs = require('fs');
const server, proxy;

const index = fs.readFileSync(`${__dirname}/index.html`);
const indexjs = fs.readFileSync(`${__dirname}/index.js`);
const bcoin = fs.readFileSync(`${__dirname}/bcoin.js`);
const master = fs.readFileSync(`${__dirname}/bcoin-master.js`);
const worker = fs.readFileSync(`${__dirname}/bcoin-worker.js`);

proxy = new WSProxy({
let proxy = new WSProxy({
pow: process.argv.indexOf('--pow') !== -1,
ports: [8333, 18333, 18444, 28333, 28901]
});

let server = new HTTPBase({
port: +process.argv[2] || 8080,
sockets: false
});

proxy.on('error', (err) => {
console.error(err.stack + '');
});

server = new HTTPBase({
port: +process.argv[2] || 8080,
sockets: false
server.on('error', (err) => {
console.error(err.stack + '');
});

server.get('/favicon.ico', (req, res) => {
Expand All @@ -49,10 +52,6 @@ server.get('/bcoin-worker.js', (req, res) => {
res.send(200, worker, 'js');
});

server.on('error', (err) => {
console.error(err.stack + '');
});

proxy.attach(server.server);

server.open();
28 changes: 21 additions & 7 deletions etc/sample.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
#

# network: main
use-workers: true
# max-workers: 4
# worker-timeout: 5000
# sigcache-size: 50000

#
# Node
Expand All @@ -19,6 +15,14 @@ db: leveldb
max-files: 64
cache-size: 100

#
# Workers
#

workers: true
# workers-size: 4
# workers-timeout: 5000

#
# Logger
#
Expand All @@ -33,7 +37,8 @@ log-file: true

prune: false
checkpoints: true
coin-cache: 40
coin-cache: 0
entry-cache: 5000
index-tx: false
index-address: false

Expand Down Expand Up @@ -83,6 +88,9 @@ identity-key: 74b4147957813b62cc8987f2b711ddb31f8cb46dcbf71502033da66053c8780a
# Always try to connect to these nodes.
# nodes: 127.0.0.1,127.0.0.2

# Only try to connect to these nodes.
# only: 127.0.0.1,127.0.0.2

#
# Miner
#
Expand All @@ -103,7 +111,13 @@ http-host: ::
# ssl: true
# ssl-cert: @/ssl/cert.crt
# ssl-key: @/ssl/priv.key
service-key: bikeshed
api-key: bikeshed
wallet-auth: false
# no-auth: false

#
# Wallet
#

wallet-witness: false
wallet-checkpoints: true
wallet-auth: false
1 change: 0 additions & 1 deletion lib/bcoin-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ bcoin.wallet = require('./wallet');
bcoin.path = require('./wallet/path');
bcoin.walletkey = require('./wallet/walletkey');
bcoin.walletdb = require('./wallet/walletdb');
bcoin.walletplugin = require('./wallet/plugin');

// Workers
bcoin.workers = require('./workers');
Expand Down
1 change: 0 additions & 1 deletion lib/bcoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ bcoin.define('wallet', './wallet');
bcoin.define('path', './wallet/path');
bcoin.define('walletkey', './wallet/walletkey');
bcoin.define('walletdb', './wallet/walletdb');
bcoin.define('walletplugin', './wallet/plugin');

// Workers
bcoin.define('workers', './workers');
Expand Down
2 changes: 1 addition & 1 deletion lib/node/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Node.prototype.initOptions = function initOptions() {
this.logger = logger.context('node');

this.workers = new WorkerPool({
enabled: config.str('workers-enabled'),
enabled: config.bool('workers'),
size: config.num('workers-size'),
timeout: config.num('workers-timeout')
});
Expand Down
2 changes: 1 addition & 1 deletion webpack.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = {
module: {
rules: [{
test: /\.js$/,
exclude: /node_modules\/(bn.js|elliptic|n64)/,
exclude: /node_modules\/(?!bcoin|elliptic|bn\.js|n64)/,
loader: 'babel-loader'
}]
},
Expand Down

0 comments on commit db0567f

Please sign in to comment.