Skip to content

Commit 14f21f9

Browse files
authored
Merge pull request #449 from braydonf/address-history-concurrency
bitcoind: get detailed transactions with concurrency
2 parents ae7359c + 3715f07 commit 14f21f9

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/services/bitcoind.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Bitcoin.DEFAULT_TRY_ALL_INTERVAL = 1000;
7676
Bitcoin.DEFAULT_REINDEX_INTERVAL = 10000;
7777
Bitcoin.DEFAULT_START_RETRY_INTERVAL = 5000;
7878
Bitcoin.DEFAULT_TIP_UPDATE_INTERVAL = 15000;
79+
Bitcoin.DEFAULT_TRANSACTION_CONCURRENCY = 5;
7980
Bitcoin.DEFAULT_CONFIG_SETTINGS = {
8081
server: 1,
8182
whitelist: '127.0.0.1',
@@ -92,6 +93,8 @@ Bitcoin.DEFAULT_CONFIG_SETTINGS = {
9293
};
9394

9495
Bitcoin.prototype._initDefaults = function(options) {
96+
/* jshint maxcomplexity: 15 */
97+
9598
// limits
9699
this.maxTxids = options.maxTxids || Bitcoin.DEFAULT_MAX_TXIDS;
97100
this.maxTransactionHistory = options.maxTransactionHistory || Bitcoin.DEFAULT_MAX_HISTORY;
@@ -106,6 +109,9 @@ Bitcoin.prototype._initDefaults = function(options) {
106109
this.tryAllInterval = options.tryAllInterval || Bitcoin.DEFAULT_TRY_ALL_INTERVAL;
107110
this.startRetryInterval = options.startRetryInterval || Bitcoin.DEFAULT_START_RETRY_INTERVAL;
108111

112+
// rpc limits
113+
this.transactionConcurrency = options.transactionConcurrency || Bitcoin.DEFAULT_TRANSACTION_CONCURRENCY;
114+
109115
// sync progress level when zmq subscribes to events
110116
this.zmqSubscribeProgress = options.zmqSubscribeProgress || Bitcoin.DEFAULT_ZMQ_SUBSCRIBE_PROGRESS;
111117
};
@@ -1412,8 +1418,9 @@ Bitcoin.prototype.getAddressHistory = function(addressArg, options, callback) {
14121418
return callback(e);
14131419
}
14141420

1415-
async.mapSeries(
1421+
async.mapLimit(
14161422
txids,
1423+
self.transactionConcurrency,
14171424
function(txid, next) {
14181425
self._getAddressDetailedTransaction(txid, {
14191426
queryMempool: queryMempool,

test/services/bitcoind.unit.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ describe('Bitcoin Service', function() {
8383
});
8484
});
8585

86+
describe('#_initDefaults', function() {
87+
it('will set transaction concurrency', function() {
88+
var bitcoind = new BitcoinService(baseConfig);
89+
bitcoind._initDefaults({transactionConcurrency: 10});
90+
bitcoind.transactionConcurrency.should.equal(10);
91+
bitcoind._initDefaults({});
92+
bitcoind.transactionConcurrency.should.equal(5);
93+
});
94+
});
95+
8696
describe('@dependencies', function() {
8797
it('will have no dependencies', function() {
8898
BitcoinService.dependencies.should.deep.equal([]);

0 commit comments

Comments
 (0)