|
@ -792,35 +792,21 @@ WalletService.prototype.getFeeLevels = function(opts, cb) { |
|
|
if (network != 'livenet' && network != 'testnet') |
|
|
if (network != 'livenet' && network != 'testnet') |
|
|
return cb(new ClientError('Invalid network')); |
|
|
return cb(new ClientError('Invalid network')); |
|
|
|
|
|
|
|
|
var levels = [{ |
|
|
var levels = WalletUtils.FEE_LEVELS; |
|
|
name: 'priority', |
|
|
|
|
|
nbBlocks: 1, |
|
|
|
|
|
defaultValue: 50000 |
|
|
|
|
|
}, { |
|
|
|
|
|
name: 'normal', |
|
|
|
|
|
nbBlocks: 4, |
|
|
|
|
|
defaultValue: 20000 |
|
|
|
|
|
}, { |
|
|
|
|
|
name: 'economy', |
|
|
|
|
|
nbBlocks: 12, |
|
|
|
|
|
defaultValue: 10000 |
|
|
|
|
|
}, ]; |
|
|
|
|
|
|
|
|
|
|
|
var samplePoints = _.uniq(_.pluck(levels, 'nbBlocks')); |
|
|
var samplePoints = _.uniq(_.pluck(levels, 'nbBlocks')); |
|
|
self._sampleFeeLevels(network, samplePoints, function(err, feeSamples) { |
|
|
self._sampleFeeLevels(network, samplePoints, function(err, feeSamples) { |
|
|
var values = _.map(levels, function(level) { |
|
|
var values = _.map(levels, function(level) { |
|
|
var feePerKB; |
|
|
var result = { |
|
|
if (err) { |
|
|
|
|
|
feePerKB = level.defaultValue; |
|
|
|
|
|
} else { |
|
|
|
|
|
var sample = feeSamples[level.nbBlocks]; |
|
|
|
|
|
feePerKB = (sample < 0) ? level.defaultValue : sample; |
|
|
|
|
|
} |
|
|
|
|
|
return { |
|
|
|
|
|
level: level.name, |
|
|
level: level.name, |
|
|
feePerKB: feePerKB, |
|
|
|
|
|
nbBlocks: level.nbBlocks, |
|
|
|
|
|
}; |
|
|
}; |
|
|
|
|
|
if (err || feeSamples[level.nbBlocks] < 0) { |
|
|
|
|
|
result.feePerKB = level.defaultValue; |
|
|
|
|
|
result.nbBlocks = null; |
|
|
|
|
|
} else { |
|
|
|
|
|
result.feePerKB = feeSamples[level.nbBlocks]; |
|
|
|
|
|
result.nbBlocks = level.nbBlocks; |
|
|
|
|
|
} |
|
|
|
|
|
return result; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
return cb(null, values); |
|
|
return cb(null, values); |
|
|