Compare commits
10 Commits
40b2e64a8f
...
35f5a82d4b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35f5a82d4b | ||
|
|
a396c4a24e | ||
|
|
fe9741fdf3 | ||
|
|
9da18c7073 | ||
|
|
7663026227 | ||
|
|
8d4f9f5a6e | ||
|
|
1d53646101 | ||
|
|
e5c86ebe5f | ||
|
|
5ab1214fa4 | ||
|
|
c5690aa490 |
@ -16,7 +16,7 @@ var utils = require('../../utils');
|
||||
var LRU = require('lru-cache');
|
||||
var XXHash = require('xxhash');
|
||||
|
||||
const MAX_TX_QUERY_LIMIT = 10;
|
||||
const MAX_TX_QUERY_LIMIT = 100;
|
||||
|
||||
// See rationale about this cache at function getTxList(next)
|
||||
const TXID_LIST_CACHE_ITEMS = 250; // nr of items (this translates to: consecutive
|
||||
@ -218,11 +218,11 @@ AddressService.prototype.getAddressHistory = function(addresses, options, stream
|
||||
if(!results.items.some(x => x.txid() === tx.txid())) //push only if tx not already in array
|
||||
results.items.unshift(tx); //using unshift, so that recent tx (low) are at front
|
||||
|
||||
if(results.items.length > MAX_TX_QUERY_LIMIT) {
|
||||
results.items.sort((a, b) => b.__height - a.__height || a.txid().localeCompare(b.txid()));
|
||||
if(results.items.length > MAX_TX_QUERY_LIMIT) { //remove items from array when overflown
|
||||
results.items.sort((a, b) => (b.__height || 0xffffffff) - (a.__height || 0xffffffff) || b.txid().localeCompare(a.txid()));
|
||||
let del_count = options.old_support ? results.items.length : results.items.length - MAX_TX_QUERY_LIMIT;
|
||||
let start_index = options.old_support ? MAX_TX_QUERY_LIMIT : 0;
|
||||
console.debug("POPED", results.items.splice(start_index, del_count).map(r => r.txid())) ;
|
||||
results.items.splice(start_index, del_count);
|
||||
}
|
||||
|
||||
}
|
||||
@ -239,7 +239,7 @@ AddressService.prototype.getAddressHistory = function(addresses, options, stream
|
||||
}
|
||||
|
||||
//sort items in desc block-height, then asc txid (if same height)
|
||||
results.items.sort((a, b) => b.__height - a.__height || a.txid().localeCompare(b.txid()));
|
||||
results.items.sort((a, b) => (b.__height || 0xffffffff) - (a.__height || 0xffffffff) || b.txid().localeCompare(a.txid()));
|
||||
results.totalCount = parseInt(results.totalCount.toFixed());
|
||||
|
||||
//Quick support for `from` and `to` options (DEPRECATED! Not recommeded to use)
|
||||
@ -848,11 +848,9 @@ AddressService.prototype._streamAddressSummary = function(address, options, stre
|
||||
//declare the queue to process tx data
|
||||
var tmpTxList = {}; //store processed txid temporarily to ignore duplication
|
||||
|
||||
let td_count = 0; //test
|
||||
var q = async.queue(function(id, cb) {
|
||||
td_count++; //test
|
||||
//duplication finding
|
||||
|
||||
//duplication finding
|
||||
if(id.txid in tmpTxList){
|
||||
|
||||
tmpTxList[id.txid][0]++;
|
||||
@ -881,7 +879,7 @@ AddressService.prototype._streamAddressSummary = function(address, options, stre
|
||||
|
||||
}, 4);
|
||||
|
||||
//q.pause(); //pause and wait until queue is set
|
||||
//q.pause(); //pause and wait until queue is set (not needed)
|
||||
|
||||
function chunkCallback(err, tx){
|
||||
|
||||
@ -921,8 +919,6 @@ AddressService.prototype._streamAddressSummary = function(address, options, stre
|
||||
|
||||
self._transaction.getTransaction(options.after, options, function(err, tx) {
|
||||
|
||||
if(!tx) console.debug(options.after + "Not found");
|
||||
|
||||
if(tx && tx.confirmations && tx.height >= options.start) {
|
||||
|
||||
options.start = tx.height;
|
||||
@ -960,9 +956,8 @@ AddressService.prototype._streamAddressSummary = function(address, options, stre
|
||||
|
||||
txIdTransformStream._transform = function(chunk, enc, cb) {
|
||||
|
||||
if(options.flag_stop){
|
||||
//stop data query
|
||||
console.debug("FLAG:", options.flag_stop)
|
||||
if(options.flag_stop){//stop data query
|
||||
console.debug("FLAG STOP:", options.flag_stop)
|
||||
return txIdTransformStream.unpipe();
|
||||
}
|
||||
|
||||
@ -1000,11 +995,15 @@ AddressService.prototype._streamAddressSummary = function(address, options, stre
|
||||
|
||||
//wait for queue to complete
|
||||
function(next) {
|
||||
console.debug("WAITING FOR DRAIN")
|
||||
q.drain = ()=> {
|
||||
console.debug("END-DRAIN", d_count, td_count);
|
||||
next();
|
||||
};
|
||||
|
||||
console.debug("WAITING FOR QUEUE TO COMPLETE", q.started)
|
||||
|
||||
if(!q.started) //No tx in query
|
||||
return next();
|
||||
|
||||
else
|
||||
q.drain = () => next();
|
||||
|
||||
}
|
||||
|
||||
], callback);
|
||||
|
||||
@ -100,13 +100,15 @@ WebService.prototype.stop = function(callback) {
|
||||
* all of the exposed HTTP routes.
|
||||
*/
|
||||
WebService.prototype.setupAllRoutes = function() {
|
||||
for(var key in this.node.services) {
|
||||
const self = this;
|
||||
|
||||
for(var key in self.node.services) {
|
||||
var subApp = new express();
|
||||
var service = this.node.services[key];
|
||||
var service = self.node.services[key];
|
||||
|
||||
if(service.getRoutePrefix && service.setupRoutes) {
|
||||
this.app.use('/' + this.node.services[key].getRoutePrefix(), subApp);
|
||||
this.node.services[key].setupRoutes(subApp, express, express_ws);
|
||||
self.app.use('/' + self.node.services[key].getRoutePrefix(), subApp);
|
||||
self.node.services[key].setupRoutes(subApp, express, a => express_ws(a, self.server));
|
||||
} else {
|
||||
log.debug('No routes defined for: ' + key);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user