mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
transactions controller - add comments
This commit is contained in:
parent
a10740af7e
commit
27b874f2c4
@ -26,6 +26,7 @@ module.exports = class TransactionController extends EventEmitter {
|
|||||||
this.txProviderUtils = new TxProviderUtil(this.query)
|
this.txProviderUtils = new TxProviderUtil(this.query)
|
||||||
this.blockTracker.on('block', this.checkForTxInBlock.bind(this))
|
this.blockTracker.on('block', this.checkForTxInBlock.bind(this))
|
||||||
this.blockTracker.on('block', this.resubmitPendingTxs.bind(this))
|
this.blockTracker.on('block', this.resubmitPendingTxs.bind(this))
|
||||||
|
// provider-engine only exploses the 'block' event, not 'latest' for 'sync'
|
||||||
this.provider._blockTracker.on('sync', this.queryPendingTxs.bind(this))
|
this.provider._blockTracker.on('sync', this.queryPendingTxs.bind(this))
|
||||||
this.signEthTx = opts.signTransaction
|
this.signEthTx = opts.signTransaction
|
||||||
this.nonceLock = Semaphore(1)
|
this.nonceLock = Semaphore(1)
|
||||||
@ -371,10 +372,12 @@ module.exports = class TransactionController extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
queryPendingTxs ({oldBlock, newBlock}) {
|
queryPendingTxs ({oldBlock, newBlock}) {
|
||||||
|
// check pending transactions on start
|
||||||
if (!oldBlock) {
|
if (!oldBlock) {
|
||||||
this._checkPendingTxs()
|
this._checkPendingTxs()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// if we synced by more than one block, check for missed pending transactions
|
||||||
const diff = Number.parseInt(newBlock.number) - Number.parseInt(oldBlock.number)
|
const diff = Number.parseInt(newBlock.number) - Number.parseInt(oldBlock.number)
|
||||||
if (diff > 1) this._checkPendingTxs()
|
if (diff > 1) this._checkPendingTxs()
|
||||||
}
|
}
|
||||||
@ -453,6 +456,8 @@ module.exports = class TransactionController extends EventEmitter {
|
|||||||
this.txProviderUtils.publishTransaction(rawTx, cb)
|
this.txProviderUtils.publishTransaction(rawTx, cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// checks the network for signed txs and
|
||||||
|
// if confirmed sets the tx status as 'confirmed'
|
||||||
_checkPendingTxs () {
|
_checkPendingTxs () {
|
||||||
var signedTxList = this.getFilteredTxList({status: 'submitted'})
|
var signedTxList = this.getFilteredTxList({status: 'submitted'})
|
||||||
if (!signedTxList.length) return
|
if (!signedTxList.length) return
|
||||||
|
Loading…
Reference in New Issue
Block a user