Browse Source

replace feePerKB with feePerKb to match rest of API

activeAddress
Ivan Socolsky 9 years ago
parent
commit
bafe84a2e0
  1. 15
      lib/expressapp.js
  2. 10
      lib/server.js
  3. 14
      test/integration/server.js

15
lib/expressapp.js

@ -247,7 +247,22 @@ ExpressApp.prototype.start = function(opts, cb) {
});
});
// DEPRECATED
router.get('/v1/feelevels/', function(req, res) {
var opts = {};
if (req.query.network) opts.network = req.query.network;
var server = getServer(req, res);
server.getFeeLevels(opts, function(err, feeLevels) {
if (err) return returnError(err, res, req);
feeLevels = _.map(feeLevels, function(feeLevel) {
feeLevel.feePerKB = feeLevel.feePerKb;
delete feeLevel.feePerKb;
});
res.json(feeLevels);
});
});
router.get('/v2/feelevels/', function(req, res) {
var opts = {};
if (req.query.network) opts.network = req.query.network;
var server = getServer(req, res);

10
lib/server.js

@ -870,11 +870,11 @@ WalletService.prototype._sampleFeeLevels = function(network, points, cb) {
}
var levels = _.zipObject(_.map(points, function(p) {
var feePerKB = _.isObject(result) ? +result[p] : -1;
if (feePerKB < 0) {
var feePerKb = _.isObject(result) ? +result[p] : -1;
if (feePerKb < 0) {
log.warn('Could not compute fee estimation (nbBlocks=' + p + ')');
}
return [p, Utils.strip(feePerKB * 1e8)];
return [p, Utils.strip(feePerKb * 1e8)];
}));
return cb(null, levels);
@ -904,10 +904,10 @@ WalletService.prototype.getFeeLevels = function(opts, cb) {
level: level.name,
};
if (err || feeSamples[level.nbBlocks] < 0) {
result.feePerKB = level.defaultValue;
result.feePerKb = level.defaultValue;
result.nbBlocks = null;
} else {
result.feePerKB = feeSamples[level.nbBlocks];
result.feePerKb = feeSamples[level.nbBlocks];
result.nbBlocks = level.nbBlocks;
}
return result;

14
test/integration/server.js

@ -1764,13 +1764,13 @@ describe('Wallet service', function() {
fees = _.zipObject(_.map(fees, function(item) {
return [item.level, item];
}));
fees.priority.feePerKB.should.equal(40000);
fees.priority.feePerKb.should.equal(40000);
fees.priority.nbBlocks.should.equal(1);
fees.normal.feePerKB.should.equal(20000);
fees.normal.feePerKb.should.equal(20000);
fees.normal.nbBlocks.should.equal(2);
fees.economy.feePerKB.should.equal(18000);
fees.economy.feePerKb.should.equal(18000);
fees.economy.nbBlocks.should.equal(6);
done();
});
@ -1780,7 +1780,7 @@ describe('Wallet service', function() {
server.getFeeLevels({}, function(err, fees) {
should.not.exist(err);
fees = _.zipObject(_.map(fees, function(item) {
return [item.level, item.feePerKB];
return [item.level, item.feePerKb];
}));
fees.priority.should.equal(50000);
fees.normal.should.equal(20000);
@ -1799,13 +1799,13 @@ describe('Wallet service', function() {
fees = _.zipObject(_.map(fees, function(item) {
return [item.level, item];
}));
fees.priority.feePerKB.should.equal(50000);
fees.priority.feePerKb.should.equal(50000);
should.not.exist(fees.priority.nbBlocks);
fees.normal.feePerKB.should.equal(18000);
fees.normal.feePerKb.should.equal(18000);
fees.normal.nbBlocks.should.equal(2);
fees.economy.feePerKB.should.equal(0);
fees.economy.feePerKb.should.equal(0);
fees.economy.nbBlocks.should.equal(6);
done();
});

Loading…
Cancel
Save