fix typo.
This commit is contained in:
parent
774f08c91f
commit
f3ea892b82
|
@ -417,22 +417,23 @@ Bitcoin.prototype.getMiningInfo = function() {
|
||||||
return bitcoindjs.getMiningInfo();
|
return bitcoindjs.getMiningInfo();
|
||||||
};
|
};
|
||||||
|
|
||||||
Bitcoin.prototype.getAddrTransactions = function(addr, callback) {
|
Bitcoin.prototype.getAddrTransactions = function(address, callback) {
|
||||||
if (!bitcoin.db) {
|
if (!bitcoin.db) {
|
||||||
var tiny = require('tiny').json;
|
var tiny = require('tiny').json;
|
||||||
|
tiny.debug = function() {};
|
||||||
bitcoin.db = tiny({
|
bitcoin.db = tiny({
|
||||||
file: process.env.HOME + '/.bitcoindjs.addr.db',
|
file: process.env.HOME + '/.bitcoindjs.addr.db',
|
||||||
saveIndex: false,
|
saveIndex: false,
|
||||||
initialCache: false
|
initialCache: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return bitcoin.db.get(addr, 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 last = found && records[records.length - 1];
|
||||||
var limit = 15 * 60 * 1000;
|
var limit = 15 * 60 * 1000;
|
||||||
if (!found || last.timestamp + limit < Date.now()) {
|
if (!found || last.timestamp + limit < Date.now()) {
|
||||||
var options = {
|
var options = {
|
||||||
address: addr,
|
address: address,
|
||||||
blockindex: (records || []).reduce(function(out, record) {
|
blockindex: (records || []).reduce(function(out, record) {
|
||||||
return record.blockindex > out
|
return record.blockindex > out
|
||||||
? record.blockindex
|
? record.blockindex
|
||||||
|
@ -443,7 +444,7 @@ Bitcoin.prototype.getAddrTransactions = function(addr, callback) {
|
||||||
if (err) return callback(err);
|
if (err) return callback(err);
|
||||||
addr = bitcoin.addr(addr);
|
addr = bitcoin.addr(addr);
|
||||||
if (addr.tx[0] && !addr.tx[0].vout[0]) {
|
if (addr.tx[0] && !addr.tx[0].vout[0]) {
|
||||||
return bitcoin.db.set(addr, [{
|
return bitcoin.db.set(address, [{
|
||||||
txid: null,
|
txid: null,
|
||||||
blockhash: null,
|
blockhash: null,
|
||||||
blockindex: null,
|
blockindex: null,
|
||||||
|
@ -467,7 +468,7 @@ Bitcoin.prototype.getAddrTransactions = function(addr, callback) {
|
||||||
timestamp: Date.now()
|
timestamp: Date.now()
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return bitcoin.db.set(addr, set, function() {
|
return bitcoin.db.set(address, set, function() {
|
||||||
return callback(null, addr);
|
return callback(null, addr);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -485,7 +486,7 @@ Bitcoin.prototype.getAddrTransactions = function(addr, callback) {
|
||||||
});
|
});
|
||||||
}, function() {
|
}, function() {
|
||||||
return callback(null, bitcoin.addr({
|
return callback(null, bitcoin.addr({
|
||||||
address: addr,
|
address: address,
|
||||||
tx: txs
|
tx: txs
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue