1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00

Default to 1 gwei for empty blocks

This commit is contained in:
Dan Finlay 2018-01-08 15:41:57 -08:00
parent 943befef91
commit d829fb91b8

View File

@ -497,8 +497,8 @@ module.exports = class MetamaskController extends EventEmitter {
}
const lowestPrices = recentBlocks.map((block) => {
if (!block.gasPrices) {
return new BN(0)
if (!block.gasPrices || block.gasPrices.length < 1) {
return GWEI_BN
}
return block.gasPrices
.map(hexPrefix => hexPrefix.substr(2))
@ -508,6 +508,7 @@ module.exports = class MetamaskController extends EventEmitter {
})[0]
})
.map(number => number.div(GWEI_BN).toNumber())
const percentileNum = percentile(50, lowestPrices)
const percentileNumBn = new BN(percentileNum)
return '0x' + percentileNumBn.mul(GWEI_BN).toString(16)