From 28a6603032560442237708c0b45fcbb1404bb618 Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Thu, 16 Jul 2015 17:47:27 -0300 Subject: [PATCH] log failed attempts to fetch network fee --- lib/server.js | 13 ++++++++----- test/integration/server.js | 16 ++++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/server.js b/lib/server.js index abf3120..e51e231 100644 --- a/lib/server.js +++ b/lib/server.js @@ -777,6 +777,9 @@ WalletService.prototype._sampleFeeLevels = function(network, points, cb) { log.error('Error estimating fee', err); return next(err); } + if (result.feePerKB < 0) { + log.warn('Could not compute fee estimation (nbBlocks=' + p + ')'); + } return next(null, [p, result.feePerKB * 1e8]); }); }, function(err, results) { @@ -802,22 +805,22 @@ WalletService.prototype.getFeeLevels = function(opts, cb) { var levels = [{ name: 'emergency', - nbBlocks: 2, + nbBlocks: 1, modifier: 1.5, defaultValue: 50000 }, { name: 'priority', - nbBlocks: 2, + nbBlocks: 1, modifier: 1, defaultValue: 20000 }, { name: 'normal', - nbBlocks: 6, + nbBlocks: 3, modifier: 1, defaultValue: 10000 }, { name: 'economy', - nbBlocks: 25, + nbBlocks: 10, modifier: 1, defaultValue: 5000 }, ]; @@ -830,7 +833,7 @@ WalletService.prototype.getFeeLevels = function(opts, cb) { feePerKB = level.defaultValue; } else { var sample = feeSamples[level.nbBlocks]; - feePerKB = (sample <= 0) ? level.defaultValue : sample * level.modifier; + feePerKB = (sample < 0) ? level.defaultValue : sample * level.modifier; } return { level: level.name, diff --git a/test/integration/server.js b/test/integration/server.js index 0a1bfbd..1a783b0 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -201,7 +201,7 @@ helpers.stubHistory = function(txs) { helpers.stubFeeLevels = function(levels) { blockchainExplorer.estimateFee = function(nbBlocks, cb) { return cb(null, { - feePerKB: levels[nbBlocks] / 1e8 || -1 + feePerKB: levels[nbBlocks] / 1e8 }); }; }; @@ -1463,9 +1463,9 @@ describe('Wallet service', function() { it('should get current fee levels', function(done) { helpers.stubFeeLevels({ - 2: 40000, - 6: 20000, - 25: 18000, + 1: 40000, + 3: 20000, + 10: 18000, }); server.getFeeLevels({}, function(err, fees) { should.not.exist(err); @@ -1495,9 +1495,9 @@ describe('Wallet service', function() { }); it('should get default fees if network cannot estimate (returns -1)', function(done) { helpers.stubFeeLevels({ - 2: -1, - 6: 18000, - 25: 0, + 1: -1, + 3: 18000, + 10: 0, }); server.getFeeLevels({}, function(err, fees) { should.not.exist(err); @@ -1507,7 +1507,7 @@ describe('Wallet service', function() { fees.emergency.should.equal(50000); fees.priority.should.equal(20000); fees.normal.should.equal(18000); - fees.economy.should.equal(5000); + fees.economy.should.equal(0); done(); }); });