Skip to content

Commit

Permalink
add concurrency option
Browse files Browse the repository at this point in the history
  • Loading branch information
fanatid committed Oct 13, 2015
1 parent 05c3ca9 commit dda1b45
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bitcoind-rpc-client",
"version": "0.2.1",
"version": "0.3.0",
"description": "Bitcoind RPC client",
"keywords": [
"bitcoin",
Expand Down Expand Up @@ -38,6 +38,7 @@
},
"dependencies": {
"babel-runtime": "^5.8.20",
"make-concurrent": "^1.1.0",
"promise-useful-utils": "^0.2.0"
},
"devDependencies": {
Expand Down
17 changes: 13 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import http from 'http'
import https from 'https'
import makeConcurrent from 'make-concurrent'

import Methods from './methods'
import BatchInterface from './batch'
Expand All @@ -21,14 +22,22 @@ export default class RpcClient extends Methods {
* @param {boolean} [opts.ssl=false]
* @param {boolean} [opts.sslStrict]
* @param {string} [opts.sslCa]
* @param {number} [opts.concurrency=Infinity]
*/
constructor (opts) {
super()

this._opts = opts || {}
this._opts.host = this._opts.host || '127.0.0.1'
this._opts.port = this._opts.port || 8332
this._opts.ssl = this._opts.ssl || false
this._opts = Object.assign({
host: '127.0.0.1',
port: 8332,
ssl: false,
concurrency: Infinity
}, opts)

if (this._opts.concurrency !== Infinity) {
this._call = makeConcurrent(
::this._call, {concurrency: this._opts.concurrency})
}
}

/**
Expand Down

0 comments on commit dda1b45

Please sign in to comment.