mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge pull request #2191 from MetaMask/direct-block-tracker
Fix for direct use of eth-block-tracker
This commit is contained in:
commit
87458dae24
@ -11,7 +11,6 @@ const async = require('async')
|
|||||||
const EthQuery = require('eth-query')
|
const EthQuery = require('eth-query')
|
||||||
const ObservableStore = require('obs-store')
|
const ObservableStore = require('obs-store')
|
||||||
const EventEmitter = require('events').EventEmitter
|
const EventEmitter = require('events').EventEmitter
|
||||||
const ethUtil = require('ethereumjs-util')
|
|
||||||
function noop () {}
|
function noop () {}
|
||||||
|
|
||||||
|
|
||||||
@ -58,9 +57,8 @@ class AccountTracker extends EventEmitter {
|
|||||||
//
|
//
|
||||||
|
|
||||||
_updateForBlock (block) {
|
_updateForBlock (block) {
|
||||||
const blockNumber = '0x' + block.number.toString('hex')
|
this._currentBlockNumber = block.number
|
||||||
this._currentBlockNumber = blockNumber
|
const currentBlockGasLimit = block.gasLimit
|
||||||
const currentBlockGasLimit = ethUtil.addHexPrefix(block.gasLimit.toString())
|
|
||||||
|
|
||||||
this.store.updateState({ currentBlockGasLimit })
|
this.store.updateState({ currentBlockGasLimit })
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ module.exports = class PendingTransactionTracker extends EventEmitter {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
queryPendingTxs ({oldBlock, newBlock}) {
|
queryPendingTxs ({ oldBlock, newBlock }) {
|
||||||
// check pending transactions on start
|
// check pending transactions on start
|
||||||
if (!oldBlock) {
|
if (!oldBlock) {
|
||||||
this._checkPendingTxs()
|
this._checkPendingTxs()
|
||||||
|
@ -84,14 +84,14 @@ describe('PendingTransactionTracker', function () {
|
|||||||
let newBlock, oldBlock
|
let newBlock, oldBlock
|
||||||
newBlock = { number: '0x01' }
|
newBlock = { number: '0x01' }
|
||||||
pendingTxTracker._checkPendingTxs = done
|
pendingTxTracker._checkPendingTxs = done
|
||||||
pendingTxTracker.queryPendingTxs({oldBlock, newBlock})
|
pendingTxTracker.queryPendingTxs({ oldBlock, newBlock })
|
||||||
})
|
})
|
||||||
it('should call #_checkPendingTxs if oldBlock and the newBlock have a diff of greater then 1', function (done) {
|
it('should call #_checkPendingTxs if oldBlock and the newBlock have a diff of greater then 1', function (done) {
|
||||||
let newBlock, oldBlock
|
let newBlock, oldBlock
|
||||||
oldBlock = { number: '0x01' }
|
oldBlock = { number: '0x01' }
|
||||||
newBlock = { number: '0x03' }
|
newBlock = { number: '0x03' }
|
||||||
pendingTxTracker._checkPendingTxs = done
|
pendingTxTracker._checkPendingTxs = done
|
||||||
pendingTxTracker.queryPendingTxs({oldBlock, newBlock})
|
pendingTxTracker.queryPendingTxs({ oldBlock, newBlock })
|
||||||
})
|
})
|
||||||
it('should not call #_checkPendingTxs if oldBlock and the newBlock have a diff of 1 or less', function (done) {
|
it('should not call #_checkPendingTxs if oldBlock and the newBlock have a diff of 1 or less', function (done) {
|
||||||
let newBlock, oldBlock
|
let newBlock, oldBlock
|
||||||
@ -101,7 +101,7 @@ describe('PendingTransactionTracker', function () {
|
|||||||
const err = new Error('should not call #_checkPendingTxs if oldBlock and the newBlock have a diff of 1 or less')
|
const err = new Error('should not call #_checkPendingTxs if oldBlock and the newBlock have a diff of 1 or less')
|
||||||
done(err)
|
done(err)
|
||||||
}
|
}
|
||||||
pendingTxTracker.queryPendingTxs({oldBlock, newBlock})
|
pendingTxTracker.queryPendingTxs({ oldBlock, newBlock })
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user