diff --git a/lib/bitcoind.js b/lib/bitcoind.js index 73afd89c..a4c8fbc1 100644 --- a/lib/bitcoind.js +++ b/lib/bitcoind.js @@ -432,66 +432,43 @@ Bitcoin.prototype.getAddrTransactions = function(address, callback) { } return bitcoin.db.get(address, function(err, records) { var found = !err && records && records.length; - var last = found && records[records.length - 1]; - var limit = 15 * 60 * 1000; - if (!found || last.timestamp + limit < Date.now()) { - var options = { - address: address, - blockindex: (records || []).reduce(function(out, record) { - return record.blockindex > out - ? record.blockindex - : out; - }, -1) - }; - return bitcoindjs.getAddrTransactions(options, function(err, addr) { - if (err) return callback(err); - addr = bitcoin.addr(addr); - if (addr.tx[0] && !addr.tx[0].vout[0]) { - return bitcoin.db.set(address, [{ - txid: null, - blockhash: null, - blockindex: null, - timestamp: Date.now() - }], function() { - return callback(null, bitcoin.addr({ - address: addr.address, - tx: [] - })); - }); - } - var set = []; - if (records && records.length) { - set = records; - } - addr.tx.forEach(function(tx) { - set.push({ - txid: tx.txid, - blockhash: tx.blockhash, - blockindex: tx.blockindex, - timestamp: Date.now() - }); + var options = { + address: address, + blockindex: (records || []).reduce(function(out, record) { + return record.blockindex > out + ? record.blockindex + : out; + }, -1) + }; + return bitcoindjs.getAddrTransactions(options, function(err, addr) { + if (err) return callback(err); + addr = bitcoin.addr(addr); + if (addr.tx[0] && !addr.tx[0].vout[0]) { + return bitcoin.db.set(address, [{ + txid: null, + blockhash: null, + blockindex: null + }], function() { + return callback(null, bitcoin.addr({ + address: addr.address, + tx: [] + })); }); - return bitcoin.db.set(address, set, function() { - return callback(null, addr); + } + var set = []; + if (records && records.length) { + set = records; + } + addr.tx.forEach(function(tx) { + set.push({ + txid: tx.txid, + blockhash: tx.blockhash, + blockindex: tx.blockindex }); }); - } - var txs = []; - return utils.forEach(records, function(record, next) { - var block = record.blockhash; - var txid = record.txid; - var index = record.blockindex; - if (txid == null) return next(); - return bitcoin.getTransaction(txid, block, function(err, tx) { - if (err) return next(); - txs.push(tx); - return next(); + return bitcoin.db.set(address, set, function() { + return callback(null, addr); }); - }, function() { - return callback(null, bitcoin.addr({ - address: address, - tx: txs - })); }); }); };