Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
Merge pull request #631 from isocolsky/feat/urgent-fee
Browse files Browse the repository at this point in the history
Add 'Urgent' fee level
  • Loading branch information
matiu authored Mar 2, 2017
2 parents 7096157 + d93cd4f commit 8a63447
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
13 changes: 9 additions & 4 deletions lib/common/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,26 @@ Defaults.MAX_MAIN_ADDRESS_GAP = 20;
Defaults.SCAN_ADDRESS_GAP = Defaults.MAX_MAIN_ADDRESS_GAP + 20;

Defaults.FEE_LEVELS = [{
name: 'urgent',
nbBlocks: 2,
multiplier: 1.5,
defaultValue: 150000,
}, {
name: 'priority',
nbBlocks: 2,
defaultValue: 50000
defaultValue: 100000
}, {
name: 'normal',
nbBlocks: 3,
defaultValue: 40000
defaultValue: 80000
}, {
name: 'economy',
nbBlocks: 6,
defaultValue: 25000
defaultValue: 50000
}, {
name: 'superEconomy',
nbBlocks: 24,
defaultValue: 10000
defaultValue: 20000
}];

Defaults.DEFAULT_FEE_PER_KB = Defaults.FEE_LEVELS[1].defaultValue;
Expand Down
2 changes: 1 addition & 1 deletion lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ WalletService.prototype.getFeeLevels = function(opts, cb) {
result.nbBlocks = null;
} else {
var feeLevel = getFeeLevel(feeSamples, level, level.nbBlocks, Defaults.FEE_LEVELS_FALLBACK);
result.feePerKb = feeLevel.feePerKb;
result.feePerKb = +(feeLevel.feePerKb * (level.multiplier || 1)).toFixed(0);
result.nbBlocks = feeLevel.nbBlocks;
}
return result;
Expand Down
8 changes: 8 additions & 0 deletions test/integration/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2146,6 +2146,11 @@ describe('Wallet service', function() {
before(function() {
levels = Defaults.FEE_LEVELS;
Defaults.FEE_LEVELS = [{
name: 'urgent',
nbBlocks: 1,
multiplier: 1.5,
defaultValue: 50000,
}, {
name: 'priority',
nbBlocks: 1,
defaultValue: 50000
Expand Down Expand Up @@ -2186,6 +2191,9 @@ describe('Wallet service', function() {
fees = _.zipObject(_.map(fees, function(item) {
return [item.level, item];
}));
fees.urgent.feePerKb.should.equal(60000);
fees.urgent.nbBlocks.should.equal(1);

fees.priority.feePerKb.should.equal(40000);
fees.priority.nbBlocks.should.equal(1);

Expand Down

0 comments on commit 8a63447

Please sign in to comment.