diff options
author | Dan Finlay <dan@danfinlay.com> | 2017-11-21 05:27:29 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2017-11-21 05:27:29 +0800 |
commit | c0aa7ce8574c6a88c348d86c71678fcd24ac168d (patch) | |
tree | a56033a0e1f2f63e8d528f8e24f86f8b4f5e98e4 | |
parent | 408bbe726f60c96d3fd2d8132900b822a1ca9fb6 (diff) | |
download | tangerine-wallet-browser-c0aa7ce8574c6a88c348d86c71678fcd24ac168d.tar tangerine-wallet-browser-c0aa7ce8574c6a88c348d86c71678fcd24ac168d.tar.gz tangerine-wallet-browser-c0aa7ce8574c6a88c348d86c71678fcd24ac168d.tar.bz2 tangerine-wallet-browser-c0aa7ce8574c6a88c348d86c71678fcd24ac168d.tar.lz tangerine-wallet-browser-c0aa7ce8574c6a88c348d86c71678fcd24ac168d.tar.xz tangerine-wallet-browser-c0aa7ce8574c6a88c348d86c71678fcd24ac168d.tar.zst tangerine-wallet-browser-c0aa7ce8574c6a88c348d86c71678fcd24ac168d.zip |
Add reproduction and mutex code
-rw-r--r-- | app/scripts/metamask-controller.js | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 968589f6e..69cf65554 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -31,6 +31,7 @@ const ConfigManager = require('./lib/config-manager') const nodeify = require('./lib/nodeify') const accountImporter = require('./account-import-strategies') const getBuyEthUrl = require('./lib/buy-eth-url') +const Mutex = require('await-semaphore').Mutex const version = require('../manifest.json').version module.exports = class MetamaskController extends EventEmitter { @@ -38,6 +39,10 @@ module.exports = class MetamaskController extends EventEmitter { constructor (opts) { super() + this.createVaultRequestStart = [] + this.createVaultRequestEnd = [] + this.createVaultMutex = new Mutex() + this.sendUpdate = debounce(this.privateSendUpdate.bind(this), 200) this.opts = opts @@ -467,15 +472,45 @@ module.exports = class MetamaskController extends EventEmitter { // Vault Management // - async createNewVaultAndKeychain (password, cb) { + async createNewVaultAndKeychain (password) { + const release = await this.createVaultMutex.acquire() + this.createVaultRequestStart.push(performance.now()) + this.createVaultRequestEnd.push(0); + const idx = this.createVaultRequestStart.length - 1; + if(idx === 1) { + await this.sleep(8000) + } const vault = await this.keyringController.createNewVaultAndKeychain(password) + if(idx === 0) { + //await this.sleep(3000) + } + console.log({ + "idx": idx, + "when": "before", + "obj": vault + }); this.selectFirstIdentity(vault) + console.log({ + "idx": idx, + "when": "after", + "obj": vault + }); + this.createVaultRequestEnd[idx] = performance.now() + console.log(this.createVaultRequestStart) + console.log(this.createVaultRequestEnd) + release() return vault } - async createNewVaultAndRestore (password, seed, cb) { + sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + + async createNewVaultAndRestore (password, seed) { + const release = await this.createVaultMutex.acquire() const vault = await this.keyringController.createNewVaultAndRestore(password, seed) this.selectFirstIdentity(vault) + release() return vault } |