diff options
author | frankiebee <frankie.diamond@gmail.com> | 2018-04-20 02:29:26 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2018-04-20 02:46:15 +0800 |
commit | eeb9390de81ce6fc92247d5c499e991dce8330bd (patch) | |
tree | 400f07cb6028e6e1f8ae5328d1c5544277de837f /app/scripts/controllers/transactions/nonce-tracker.js | |
parent | 943eea043cc40ea42ffe757a7115ccbc5585b37b (diff) | |
download | tangerine-wallet-browser-eeb9390de81ce6fc92247d5c499e991dce8330bd.tar tangerine-wallet-browser-eeb9390de81ce6fc92247d5c499e991dce8330bd.tar.gz tangerine-wallet-browser-eeb9390de81ce6fc92247d5c499e991dce8330bd.tar.bz2 tangerine-wallet-browser-eeb9390de81ce6fc92247d5c499e991dce8330bd.tar.lz tangerine-wallet-browser-eeb9390de81ce6fc92247d5c499e991dce8330bd.tar.xz tangerine-wallet-browser-eeb9390de81ce6fc92247d5c499e991dce8330bd.tar.zst tangerine-wallet-browser-eeb9390de81ce6fc92247d5c499e991dce8330bd.zip |
meta - transactions - docs yo!
Diffstat (limited to 'app/scripts/controllers/transactions/nonce-tracker.js')
-rw-r--r-- | app/scripts/controllers/transactions/nonce-tracker.js | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/app/scripts/controllers/transactions/nonce-tracker.js b/app/scripts/controllers/transactions/nonce-tracker.js index 5b1cd7f43..e0f4d0fe3 100644 --- a/app/scripts/controllers/transactions/nonce-tracker.js +++ b/app/scripts/controllers/transactions/nonce-tracker.js @@ -1,7 +1,15 @@ const EthQuery = require('ethjs-query') const assert = require('assert') const Mutex = require('await-semaphore').Mutex - +/** + @param opts {object} - + @property {Object} opts.provider a ethereum provider + @property {function} opts.getPendingTransactions a function that returns an array of txMeta + whos status is `submitted` + @property {function} opts.getConfirmedTransactions a function that returns an array of txMeta + whos status is `confirmed` + @class +*/ class NonceTracker { constructor ({ provider, getPendingTransactions, getConfirmedTransactions }) { @@ -12,6 +20,9 @@ class NonceTracker { this.lockMap = {} } + /** + @returns {object} with the key releaseLock (the gloabl mutex) + */ async getGlobalLock () { const globalMutex = this._lookupMutex('global') // await global mutex free @@ -19,8 +30,19 @@ class NonceTracker { return { releaseLock } } - // releaseLock must be called - // releaseLock must be called after adding signed tx to pending transactions (or discarding) + /** + this will return an object with the `nextNonce` `nonceDetails` which is an + object with: + highestLocallyConfirmed (nonce), + highestSuggested (either the network nonce or the highestLocallyConfirmed nonce), + nextNetworkNonce (the nonce suggested by the network), + and the releaseLock + <br>note: releaseLock must be called after adding signed tx to pending transactions + (or discarding)<br> + + @param address {string} the hex string for the address whos nonce we are calculating + @returns {object} + */ async getNonceLock (address) { // await global mutex free await this._globalMutexFree() |