Browse Source

log failed attempts to fetch network fee

activeAddress
Ivan Socolsky 10 years ago
parent
commit
28a6603032
  1. 13
      lib/server.js
  2. 16
      test/integration/server.js

13
lib/server.js

@ -777,6 +777,9 @@ WalletService.prototype._sampleFeeLevels = function(network, points, cb) {
log.error('Error estimating fee', err); log.error('Error estimating fee', err);
return next(err); return next(err);
} }
if (result.feePerKB < 0) {
log.warn('Could not compute fee estimation (nbBlocks=' + p + ')');
}
return next(null, [p, result.feePerKB * 1e8]); return next(null, [p, result.feePerKB * 1e8]);
}); });
}, function(err, results) { }, function(err, results) {
@ -802,22 +805,22 @@ WalletService.prototype.getFeeLevels = function(opts, cb) {
var levels = [{ var levels = [{
name: 'emergency', name: 'emergency',
nbBlocks: 2, nbBlocks: 1,
modifier: 1.5, modifier: 1.5,
defaultValue: 50000 defaultValue: 50000
}, { }, {
name: 'priority', name: 'priority',
nbBlocks: 2, nbBlocks: 1,
modifier: 1, modifier: 1,
defaultValue: 20000 defaultValue: 20000
}, { }, {
name: 'normal', name: 'normal',
nbBlocks: 6, nbBlocks: 3,
modifier: 1, modifier: 1,
defaultValue: 10000 defaultValue: 10000
}, { }, {
name: 'economy', name: 'economy',
nbBlocks: 25, nbBlocks: 10,
modifier: 1, modifier: 1,
defaultValue: 5000 defaultValue: 5000
}, ]; }, ];
@ -830,7 +833,7 @@ WalletService.prototype.getFeeLevels = function(opts, cb) {
feePerKB = level.defaultValue; feePerKB = level.defaultValue;
} else { } else {
var sample = feeSamples[level.nbBlocks]; var sample = feeSamples[level.nbBlocks];
feePerKB = (sample <= 0) ? level.defaultValue : sample * level.modifier; feePerKB = (sample < 0) ? level.defaultValue : sample * level.modifier;
} }
return { return {
level: level.name, level: level.name,

16
test/integration/server.js

@ -201,7 +201,7 @@ helpers.stubHistory = function(txs) {
helpers.stubFeeLevels = function(levels) { helpers.stubFeeLevels = function(levels) {
blockchainExplorer.estimateFee = function(nbBlocks, cb) { blockchainExplorer.estimateFee = function(nbBlocks, cb) {
return cb(null, { 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) { it('should get current fee levels', function(done) {
helpers.stubFeeLevels({ helpers.stubFeeLevels({
2: 40000, 1: 40000,
6: 20000, 3: 20000,
25: 18000, 10: 18000,
}); });
server.getFeeLevels({}, function(err, fees) { server.getFeeLevels({}, function(err, fees) {
should.not.exist(err); 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) { it('should get default fees if network cannot estimate (returns -1)', function(done) {
helpers.stubFeeLevels({ helpers.stubFeeLevels({
2: -1, 1: -1,
6: 18000, 3: 18000,
25: 0, 10: 0,
}); });
server.getFeeLevels({}, function(err, fees) { server.getFeeLevels({}, function(err, fees) {
should.not.exist(err); should.not.exist(err);
@ -1507,7 +1507,7 @@ describe('Wallet service', function() {
fees.emergency.should.equal(50000); fees.emergency.should.equal(50000);
fees.priority.should.equal(20000); fees.priority.should.equal(20000);
fees.normal.should.equal(18000); fees.normal.should.equal(18000);
fees.economy.should.equal(5000); fees.economy.should.equal(0);
done(); done();
}); });
}); });

Loading…
Cancel
Save