From 4481e6eb99b0eabbc423a0eb0fa405d93cc4ba57 Mon Sep 17 00:00:00 2001 From: Anthony Laibe Date: Fri, 7 Sep 2018 11:11:16 +0100 Subject: [PATCH 1/2] Ens config is run only once --- lib/modules/ens/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/modules/ens/index.js b/lib/modules/ens/index.js index 8fbe6560..bd7eb65e 100644 --- a/lib/modules/ens/index.js +++ b/lib/modules/ens/index.js @@ -14,6 +14,7 @@ class ENS { this.namesConfig = embark.config.namesystemConfig; this.registration = this.namesConfig.register || {}; this.embark = embark; + this.firstDeployDone = false; if (this.namesConfig === {} || this.namesConfig.enabled !== true || @@ -34,6 +35,9 @@ class ENS { } setProviderAndRegisterDomains(cb) { + if(this.firstDeployDone) { + return cb(); + } const self = this; async.parallel([ function getENSRegistry(paraCb) { @@ -78,6 +82,7 @@ class ENS { return cb(); } self.registerConfigDomains(config, cb); + self.firstDeployDone = true; }); } From 4c580dd54dcb67a130c7cfae3c41f2206e2a16a0 Mon Sep 17 00:00:00 2001 From: Anthony Laibe Date: Fri, 7 Sep 2018 14:57:49 +0100 Subject: [PATCH 2/2] Pr feedback using once --- lib/modules/ens/index.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/modules/ens/index.js b/lib/modules/ens/index.js index bd7eb65e..bef34d59 100644 --- a/lib/modules/ens/index.js +++ b/lib/modules/ens/index.js @@ -14,7 +14,6 @@ class ENS { this.namesConfig = embark.config.namesystemConfig; this.registration = this.namesConfig.register || {}; this.embark = embark; - this.firstDeployDone = false; if (this.namesConfig === {} || this.namesConfig.enabled !== true || @@ -29,15 +28,12 @@ class ENS { } registerEvents() { - this.embark.registerActionForEvent("contracts:deploy:afterAll", this.setProviderAndRegisterDomains.bind(this)); + this.events.once("contracts:deploy:afterAll", this.setProviderAndRegisterDomains.bind(this)); this.events.setCommandHandler("storage:ens:associate", this.associateStorageToEns.bind(this)); } setProviderAndRegisterDomains(cb) { - if(this.firstDeployDone) { - return cb(); - } const self = this; async.parallel([ function getENSRegistry(paraCb) { @@ -82,7 +78,6 @@ class ENS { return cb(); } self.registerConfigDomains(config, cb); - self.firstDeployDone = true; }); }