Fix getlasttxs api
-Completely removed the /ext/getlasttxsajax api and replaced with /ext/getlasttxs -Fixed record count for movement page
This commit is contained in:
+25
-10
@@ -422,17 +422,32 @@ module.exports = {
|
||||
},
|
||||
|
||||
get_last_txs_ajax: function(start, length, min, cb) {
|
||||
// Lookup the coin stats to get the txes value which is used to determine the total # of records
|
||||
Stats.findOne({coin:settings.coin}, function(err, stats) {
|
||||
// Get last transactions where there is at least 1 vout
|
||||
Tx.find({'total': {$gte: min}, 'vout': { $gte: { $size: 1 }}}).sort({blockindex: -1}).skip(Number(start)).limit(Number(length)).exec(function(err, txs) {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
} else {
|
||||
return cb(txs, stats.txes);
|
||||
}
|
||||
// check if min is greater than zero
|
||||
if (min > 0) {
|
||||
// min is greater than zero which means we must pull record count from the txes collection
|
||||
Tx.find({'total': {$gte: min}}).countDocuments(function(err, count) {
|
||||
// Get last transactions where there is at least 1 vout
|
||||
Tx.find({'total': {$gte: min}, 'vout': { $gte: { $size: 1 }}}).sort({blockindex: -1}).skip(Number(start)).limit(Number(length)).exec(function(err, txs) {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
} else {
|
||||
return cb(txs, count);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
// min is zero (shouldn't ever be negative) which means we must pull record count from the coinstats collection (pulling from txes could potentially take a long time because it would include coinbase txes)
|
||||
Stats.findOne({coin:settings.coin}, function(err, stats) {
|
||||
// Get last transactions where there is at least 1 vout
|
||||
Tx.find({'total': {$gte: min}, 'vout': { $gte: { $size: 1 }}}).sort({blockindex: -1}).skip(Number(start)).limit(Number(length)).exec(function(err, txs) {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
} else {
|
||||
return cb(txs, stats.txes);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
get_address_txs_ajax: function(hash, start, length, cb) {
|
||||
|
||||
Reference in New Issue
Block a user