Skip to content

Commit

Permalink
Merge pull request #50 from arqma/with-zmq
Browse files Browse the repository at this point in the history
more zmq changes
  • Loading branch information
ArqTras authored Apr 9, 2020
2 parents 9f4f335 + 28f5435 commit 9779105
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
13 changes: 9 additions & 4 deletions src-electron/main-process/modules/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ export class Backend {
break;

case "save_pool_config":
const originalServerState = this.config_data.pool.server.enabled
Object.keys(params).map(key => {
this.config_data.pool[key] = Object.assign(this.config_data.pool[key], params[key])
})
Expand All @@ -299,11 +300,15 @@ export class Backend {
config: this.config_data
})

if(this.config_data.pool.server.enabled) {
this.pool.init(this.config_data)
this.pool.startWithZmq()
this.pool.init(this.config_data)
if(!originalServerState) {
if (this.config_data.pool.server.enabled && this.config_data.daemon.type === "local_zmq") {
this.pool.startWithZmq()
}
} else {
this.pool.stop()
if (!this.config_data.pool.server.enabled) {
this.pool.stop()
}
}
})
break
Expand Down
7 changes: 2 additions & 5 deletions src-electron/main-process/modules/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ export class Pool {
this.active = false
this.config = null
this.server = null
this.zmq_enabled = false
this.isPoolRunning = false
this.id = 0
this.agent = new http.Agent({keepAlive: true, maxSockets: 1})
this.dealer = {}
this.dealer = null

this.intervals = {
startup: null,
Expand Down Expand Up @@ -109,7 +108,6 @@ export class Pool {
valid: []
}
this.connections = {}
this.zmq_enabled = this.daemon_type === "local_zmq"
if(this.daemon_type !== "local_zmq") {

if(update_work) {
Expand Down Expand Up @@ -284,7 +282,6 @@ export class Pool {
this.dealer.connect(`tcp://${options.zmq_bind_ip}:${options.zmq_bind_port}`);
console.log(`Pool Dealer connected to port ${options.zmq_bind_ip}:${options.zmq_bind_port}`);
const zmqDirector = fromEvent(this.dealer, "message");
this.zmq_enabled = true
zmqDirector.subscribe(x => {
let json = JSON.parse(x.toString());
this.addBlockAndInformMiners(json)
Expand Down Expand Up @@ -755,7 +752,7 @@ export class Pool {
delete this.connections[connection_id]
}

if (this.zmq_enabled) {
if (this.dealer) {
logger.log("warn", "Closing ZMQ")
this.dealer.send(['', 'EVICT']);
this.dealer.close()
Expand Down

0 comments on commit 9779105

Please sign in to comment.