dont bother with timestamp on caching.
This commit is contained in:
parent
09ed50b7ad
commit
04036146cb
@ -432,9 +432,6 @@ Bitcoin.prototype.getAddrTransactions = function(address, callback) {
|
|||||||
}
|
}
|
||||||
return bitcoin.db.get(address, function(err, records) {
|
return bitcoin.db.get(address, function(err, records) {
|
||||||
var found = !err && records && records.length;
|
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 = {
|
var options = {
|
||||||
address: address,
|
address: address,
|
||||||
blockindex: (records || []).reduce(function(out, record) {
|
blockindex: (records || []).reduce(function(out, record) {
|
||||||
@ -450,8 +447,7 @@ Bitcoin.prototype.getAddrTransactions = function(address, callback) {
|
|||||||
return bitcoin.db.set(address, [{
|
return bitcoin.db.set(address, [{
|
||||||
txid: null,
|
txid: null,
|
||||||
blockhash: null,
|
blockhash: null,
|
||||||
blockindex: null,
|
blockindex: null
|
||||||
timestamp: Date.now()
|
|
||||||
}], function() {
|
}], function() {
|
||||||
return callback(null, bitcoin.addr({
|
return callback(null, bitcoin.addr({
|
||||||
address: addr.address,
|
address: addr.address,
|
||||||
@ -467,32 +463,13 @@ Bitcoin.prototype.getAddrTransactions = function(address, callback) {
|
|||||||
set.push({
|
set.push({
|
||||||
txid: tx.txid,
|
txid: tx.txid,
|
||||||
blockhash: tx.blockhash,
|
blockhash: tx.blockhash,
|
||||||
blockindex: tx.blockindex,
|
blockindex: tx.blockindex
|
||||||
timestamp: Date.now()
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return bitcoin.db.set(address, set, function() {
|
return bitcoin.db.set(address, set, function() {
|
||||||
return callback(null, addr);
|
return callback(null, addr);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
|
||||||
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();
|
|
||||||
});
|
|
||||||
}, function() {
|
|
||||||
return callback(null, bitcoin.addr({
|
|
||||||
address: address,
|
|
||||||
tx: txs
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user