aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2018-08-22 07:30:11 +0800
committerkumavis <aaron@kumavis.me>2018-08-22 07:30:11 +0800
commit3ac2b40dcf4b60f13184ff8b97f9099a6a22852e (patch)
treeb9ef651d25c5fdd7d896238f7ad4076a9ee4001b /app
parentbabd59a2dc64e15ef2a415e349ef12d5b995e2e7 (diff)
downloadtangerine-wallet-browser-3ac2b40dcf4b60f13184ff8b97f9099a6a22852e.tar.gz
tangerine-wallet-browser-3ac2b40dcf4b60f13184ff8b97f9099a6a22852e.tar.zst
tangerine-wallet-browser-3ac2b40dcf4b60f13184ff8b97f9099a6a22852e.zip
metamask controller - track active controller connections
Diffstat (limited to 'app')
-rw-r--r--app/scripts/metamask-controller.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 29838ad2d..9082daac9 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -67,6 +67,10 @@ module.exports = class MetamaskController extends EventEmitter {
const initState = opts.initState || {}
this.recordFirstTimeInfo(initState)
+ // this keeps track of how many "controllerStream" connections are open
+ // the only thing that uses controller connections are open metamask UI instances
+ this.activeControllerConnections = 0
+
// platform-specific api
this.platform = opts.platform
@@ -1209,11 +1213,19 @@ module.exports = class MetamaskController extends EventEmitter {
setupControllerConnection (outStream) {
const api = this.getApi()
const dnode = Dnode(api)
+ // report new active controller connection
+ this.activeControllerConnections++
+ this.emit('controllerConnectionChanged', this.activeControllerConnections)
+ // connect dnode api to remote connection
pump(
outStream,
dnode,
outStream,
(err) => {
+ // report new active controller connection
+ this.activeControllerConnections--
+ this.emit('controllerConnectionChanged', this.activeControllerConnections)
+ // report any error
if (err) log.error(err)
}
)