Rename api for getlasttxsajax to getlasttxs
This commit is contained in:
@@ -204,31 +204,15 @@ app.use('/ext/getbasicstats', function(req,res){
|
||||
});
|
||||
});
|
||||
|
||||
app.use('/ext/getlasttxsajax/:min', function(req,res){
|
||||
if(typeof req.query.length === 'undefined' || isNaN(req.query.length) || req.query.length > settings.index.last_txs){
|
||||
req.query.length = settings.index.last_txs;
|
||||
}
|
||||
if(typeof req.query.start === 'undefined' || isNaN(req.query.start) || req.query.start < 0){
|
||||
req.query.start = 0;
|
||||
}
|
||||
if(typeof req.params.min === 'undefined' || isNaN(req.params.min ) || req.params.min < 0){
|
||||
req.params.min = 0;
|
||||
} else {
|
||||
req.params.min = (req.params.min * 100000000);
|
||||
}
|
||||
db.get_last_txs_ajax(req.query.start, req.query.length, req.params.min,function(txs, count){
|
||||
var data = [];
|
||||
for(i=0; i<txs.length; i++){
|
||||
var row = [];
|
||||
row.push(txs[i].blockindex);
|
||||
row.push(txs[i].blockhash);
|
||||
row.push(txs[i].txid);
|
||||
row.push(txs[i].vout.length);
|
||||
row.push((txs[i].total));
|
||||
row.push(new Date((txs[i].timestamp) * 1000).toUTCString());
|
||||
data.push(row);
|
||||
}
|
||||
res.json({"data":data, "draw": req.query.draw, "recordsTotal": count, "recordsFiltered": count});
|
||||
app.use('/ext/getlasttxs/:min', function(req, res) {
|
||||
db.get_last_txs(req, function(data, draw, count) {
|
||||
res.json({"data":data, "draw": draw, "recordsTotal": count, "recordsFiltered": count});
|
||||
});
|
||||
});
|
||||
|
||||
app.use('/ext/getlasttxsajax/:min', function(req, res){
|
||||
db.get_last_txs(req, function(data, draw, count) {
|
||||
res.json({"data":data, "draw": draw, "recordsTotal": count, "recordsFiltered": count});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -393,6 +393,32 @@ module.exports = {
|
||||
});
|
||||
},
|
||||
|
||||
get_last_txs: function(req, cb) {
|
||||
if (typeof req.query.length === 'undefined' || isNaN(req.query.length) || req.query.length > settings.index.last_txs)
|
||||
req.query.length = settings.index.last_txs;
|
||||
if (typeof req.query.start === 'undefined' || isNaN(req.query.start) || req.query.start < 0)
|
||||
req.query.start = 0;
|
||||
if (typeof req.params.min === 'undefined' || isNaN(req.params.min ) || req.params.min < 0)
|
||||
req.params.min = 0;
|
||||
else
|
||||
req.params.min = (req.params.min * 100000000);
|
||||
|
||||
this.get_last_txs_ajax(req.query.start, req.query.length, req.params.min,function(txs, count) {
|
||||
var data = [];
|
||||
for(i=0; i<txs.length; i++) {
|
||||
var row = [];
|
||||
row.push(txs[i].blockindex);
|
||||
row.push(txs[i].blockhash);
|
||||
row.push(txs[i].txid);
|
||||
row.push(txs[i].vout.length);
|
||||
row.push((txs[i].total));
|
||||
row.push(new Date((txs[i].timestamp) * 1000).toUTCString());
|
||||
data.push(row);
|
||||
}
|
||||
return cb(data, req.query.draw, count);
|
||||
});
|
||||
},
|
||||
|
||||
get_last_txs_ajax: function(start, length, min, cb) {
|
||||
Tx.find({'total': {$gte: min}}).countDocuments(function(err, count){
|
||||
Tx.find({'total': {$gte: min}}).sort({blockindex: -1}).skip(Number(start)).limit(Number(length)).exec(function(err, txs){
|
||||
|
||||
+2
-2
@@ -152,12 +152,12 @@ block content
|
||||
a(href='/ext/getbalance/' + hashes.address) #{address}/ext/getbalance/#{hashes.address}
|
||||
li
|
||||
p
|
||||
div(style='font-weight:bold;') getlasttxsajax (/ext/getlasttxsajax/min)
|
||||
div(style='font-weight:bold;') getlasttxs (/ext/getlasttxs/min)
|
||||
div
|
||||
em Returns last transactions greater than [min]
|
||||
div
|
||||
em Note: returned values are in satoshis
|
||||
a(href='/ext/getlasttxsajax/100') #{address}/ext/getlasttxsajax/100
|
||||
a(href='/ext/getlasttxs/100') #{address}/ext/getlasttxs/100
|
||||
li
|
||||
p
|
||||
div(style='font-weight:bold;') getcurrentprice
|
||||
|
||||
Reference in New Issue
Block a user