diff --git a/package-lock.json b/package-lock.json index 6830e70..3dcf974 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "arqma-electron-wallet", - "version": "3.0.1", + "version": "3.0.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -7802,14 +7802,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -7824,20 +7822,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -7954,8 +7949,7 @@ "inherits": { "version": "2.0.4", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -7967,7 +7961,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -7982,7 +7975,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -7990,14 +7982,12 @@ "minimist": { "version": "1.2.5", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.9.0", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -8016,7 +8006,6 @@ "version": "0.5.3", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "^1.2.5" } @@ -8078,8 +8067,7 @@ "npm-normalize-package-bin": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "npm-packlist": { "version": "1.4.8", @@ -8107,8 +8095,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -8120,7 +8107,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -8234,7 +8220,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", diff --git a/package.json b/package.json index e15a3d2..d8a4663 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "arqma-electron-wallet", - "version": "3.0.1", + "version": "3.0.2", "daemonVersion": "6.0.2", "description": "Modern GUI interface for Arqma Currency", "productName": "Arqma Electron Wallet", diff --git a/quasar.conf.js b/quasar.conf.js index b35a4c5..e52dfba 100644 --- a/quasar.conf.js +++ b/quasar.conf.js @@ -110,7 +110,8 @@ module.exports = function (ctx) { "QTh", "QTr", "QTd", - "QTableColumns" + "QTableColumns", + "QSlider" ], directives: [ "Ripple", diff --git a/src-electron/main-process/modules/backend.js b/src-electron/main-process/modules/backend.js index 53e037b..cddcfb3 100644 --- a/src-electron/main-process/modules/backend.js +++ b/src-electron/main-process/modules/backend.js @@ -151,11 +151,11 @@ export class Backend { enabled: true, startDiff: 5000, minDiff: 1000, - maxDiff: 100000000, - targetTime: 30, + maxDiff: 1000000, + targetTime: 45, retargetTime: 60, - variancePercent: 30, - maxJump: 100, + variancePercent: 45, + maxJump: 30, fixedDiffSeparator: ".", }, }, @@ -204,7 +204,7 @@ export class Backend { if (this.config_data.pool.server.enabled) { if (this.config_data.daemon.type === 'local_zmq') { if(event === "set_daemon_data") { - if(data.info.isDaemonSyncd) { + if(data.info && data.info.hasOwnProperty("isDaemonSyncd") && data.info.isDaemonSyncd) { this.pool.startWithZmq() } } @@ -240,7 +240,6 @@ export class Backend { handle(data) { let params = data.data - switch (data.method) { case "set_language": this.send("set_language", { lang: params.lang }) @@ -299,7 +298,7 @@ export class Backend { this.send("set_app_data", { config: this.config_data }) - + this.pool.init(this.config_data) if(!originalServerState) { if (this.config_data.pool.server.enabled && this.config_data.daemon.type === "local_zmq") { diff --git a/src-electron/main-process/modules/daemon.js b/src-electron/main-process/modules/daemon.js index 974c345..280f643 100644 --- a/src-electron/main-process/modules/daemon.js +++ b/src-electron/main-process/modules/daemon.js @@ -244,13 +244,14 @@ export class Daemon { zmqDirector.subscribe(x => { let daemon_info = { } - let results = JSON.parse(x.toString()); - results.result.info.isDaemonSyncd = false - if (results.result.info.height === results.result.info.target_height && results.result.info.height >= this.remote_height) { - results.result.info.isDaemonSyncd = true - } - daemon_info.info = results.result.info + let json = JSON.parse(x.toString()); + json.result.info.isDaemonSyncd = false + daemon_info.info = json.result.info this.daemon_info = daemon_info + if (json.result.info.height === json.result.info.target_height && json.result.info.height >= this.remote_height) { + json.result.info.isDaemonSyncd = true + } + this.sendGateway("set_daemon_data", daemon_info) }) } @@ -262,7 +263,15 @@ export class Daemon { case "ban_peer": this.banPeer(params.host, params.seconds) break - + case "get_peers": + clearInterval(this.heartbeat_slow) + if (params.enabled) { + this.heartbeat_slow = setInterval(() => { + this.heartbeatSlowAction() + }, 10 * 1000) // 30 seconds + this.heartbeatSlowAction() + } + break default: } } @@ -377,13 +386,6 @@ export class Daemon { this.heartbeatAction() }, this.local ? 5 * 1000 : 30 * 1000) // 5 seconds for local daemon, 30 seconds for remote this.heartbeatAction() - - clearInterval(this.heartbeat_slow) - this.heartbeat_slow = setInterval(() => { - this.heartbeatSlowAction() - }, 30 * 1000) // 30 seconds - this.heartbeatSlowAction() - } heartbeatAction() { @@ -415,12 +417,12 @@ export class Daemon { }) } - heartbeatSlowAction() { + heartbeatSlowAction(daemon_info = {}) { let actions = [] if(this.local) { actions = [ this.getRPC("connections"), - this.getRPC("bans"), + this.getRPC("bans") //this.getRPC("txpool_backlog"), ] } else { @@ -432,8 +434,7 @@ export class Daemon { if(actions.length === 0) return Promise.all(actions).then((data) => { - let daemon_info = { - } + for (let n of data) { if(n == undefined || !n.hasOwnProperty("result") || n.result == undefined) continue diff --git a/src-electron/main-process/modules/pool.js b/src-electron/main-process/modules/pool.js index f213a21..3be01f6 100644 --- a/src-electron/main-process/modules/pool.js +++ b/src-electron/main-process/modules/pool.js @@ -74,7 +74,7 @@ export class Pool { this.port = options.daemon.rpc_bind_port try { - + this.sendStatus(0) if(this.database.db == null) { this.database.start() logger.log("info", "Database initialized") @@ -91,7 +91,8 @@ export class Pool { let update_work = false if(!start && this.active) { - if(this.config.mining.address != options.pool.mining.address || this.config.mining.uniform != options.pool.mining.uniform) { + + if(this.config.mining.address != options.pool.mining.address) { update_work = true } } @@ -112,6 +113,7 @@ export class Pool { this.connections = {} this.BlockTemplateParameters = this.calculateBlockTemplateParameters() + const wallet_address = this.config.mining.address; this.address_abbr = `${wallet_address.substring(0, 5)}...${wallet_address.substring(wallet_address.length - 5)}` @@ -140,20 +142,21 @@ export class Pool { } } - startWithZmq() { + startWithZmq(isDaemonSyncd = false) { if(this.daemon_type === "local_zmq") { if(this.isPoolRunning) return - this.isPoolRunning = true + this.isPoolRunning = true logger.log("info", "Starting pool with ZMQ") this.startZMQ(this.backend.config_data.daemon) let getblocktemplate = {"jsonrpc": "2.0", "id": "1", "method": "get_block_template", - "params": this.blocktemplateparameters} + "params": this.BlockTemplateParameters} + this.dealer.send(['', JSON.stringify(getblocktemplate)]) this.startHeartbeat() this.startServer().then(() => { - this.sendStatus(2) + this.sendStatus(1) }).catch(error => { this.sendStatus(-1) }) @@ -274,10 +277,10 @@ export class Pool { this.dealer.identity = this.randomString(); this.dealer.setsockopt(zmq.ZMQ_LINGER, 0) 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}`); + logger.log("info", `Pool Dealer connected to port ${options.zmq_bind_ip}:${options.zmq_bind_port}`); const zmqDirector = fromEvent(this.dealer, "message"); zmqDirector.subscribe(x => { - let json = JSON.parse(x.toString()); + let json = JSON.parse(x.toString()); this.addBlockAndInformMiners(json) }) } @@ -338,6 +341,7 @@ export class Pool { if(this.intervals.retarget) { clearInterval(this.intervals.retarget) } + const retargetTime = this.config ? this.config.varDiff.retargetTime : 60 this.intervals.retarget = setInterval(() => { for(let connection_id in this.connections) { const miner = this.connections[connection_id] @@ -345,7 +349,7 @@ export class Pool { logger.log("info", "Difficulty change { old: %d, new: %d } for %s@%s", [miner.difficulty.last, miner.difficulty.now, miner.workerName, miner.ip]) } } - }, this.config.varDiff.retargetTime * 1000) + }, retargetTime * 1000) } startServer() { @@ -622,12 +626,12 @@ export class Pool { calculateBlockTemplateParameters() { return {wallet_address: this.config.mining.address, - reserve_size: (this.config.mining.uniform || Object.keys(this.connections).length > 128) ? 8 : 1} + reserve_size: (true || Object.keys(this.connections).length > 128) ? 8 : 1} } addBlockAndInformMiners(data, force=false) { try { - const uniform = this.config.mining.uniform || Object.keys(this.connections).length > 128 + const uniform = true || Object.keys(this.connections).length > 128 if(data.hasOwnProperty("error")) { logger.log("error", "Error polling get_block_template %j", [data.error.message]) return data.error.message @@ -635,9 +639,9 @@ export class Pool { const block = data.result if(this.blocks == null || this.blocks.current == null || this.blocks.current.height < block.height || force) { - - logger.log("info", "New block to mine { address: %s, height: %d, difficulty: %d, uniform: %s }", [this.address_abbr, block.height, block.difficulty, uniform]) + logger.log("info", "New block to mine { address: %s, height: %d, difficulty: %d, uniform: %s }", [this.address_abbr, block.height, block.difficulty, uniform]) + this.sendStatus(2) this.blocks.current = new Block(this, block, uniform) this.blocks.valid.push(this.blocks.current) @@ -652,7 +656,7 @@ export class Pool { } } } - catch(error) {console.log('sheit ', error)} + catch(error) {} return null } diff --git a/src/components/pool.vue b/src/components/pool.vue index 49cc635..4147124 100644 --- a/src/components/pool.vue +++ b/src/components/pool.vue @@ -1,6 +1,6 @@ + + diff --git a/src/components/settings.vue b/src/components/settings.vue index 19f93ec..632dd90 100644 --- a/src/components/settings.vue +++ b/src/components/settings.vue @@ -2,7 +2,7 @@ - + Settings @@ -13,6 +13,8 @@ toggle-color="primary" size="md" :options="tabs" + @input="getPeers(true)" + /> @@ -79,7 +81,7 @@ Peer list - + {{ entry.address }} Height: {{ entry.height }} @@ -156,7 +158,8 @@ export default { notify_no_payment_id: null, notify_empty_password: null, timeout: 10, - isVisible: false + isVisible: false, + enableGetPeers: false } }, mounted: function () { @@ -230,7 +233,25 @@ export default { } }, methods: { + getPeers(value){ + if (this.config.daemon.type && !this.config.daemon.type.includes("remote")) { + if (this.page === "peers") { + if (value && !this.enableGetPeers ) { + this.enableGetPeers = value + this.$gateway.send("daemon", "get_peers", {enabled: true}) + } + } else { + this.enableGetPeers = false + this.$gateway.send("daemon", "get_peers", {enabled: false}) + } + } + if (!value) { + this.enableGetPeers = value + this.isVisible = value + } + }, save() { + this.$gateway.send("daemon", "get_peers", {enabled: false}) this.$gateway.send("core", "save_config", this.pending_config); this.isVisible = false }, diff --git a/src/index.template.html b/src/index.template.html index b2d06f0..37c8dd3 100644 --- a/src/index.template.html +++ b/src/index.template.html @@ -3,6 +3,7 @@ +