Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Commit

Permalink
added miner text
Browse files Browse the repository at this point in the history
  • Loading branch information
frozeman committed Dec 3, 2015
1 parent 64421b2 commit 1b764b7
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
6 changes: 6 additions & 0 deletions interface/client/templates/elements/nodeInfo.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<template name="elements_nodeInfo">
<div class="node-info">
{{#if TemplateVar.get "mining"}}
<span data-tooltip="Mining" class="simptip-position-left simptip-movable">⛏ {{TemplateVar.get "mining"}} KH/s</span>
&nbsp;&nbsp;|&nbsp;&nbsp;
{{/if}}


{{#if $eq (TemplateVar.get "network") "test"}}
<span class="orange" style="font-weight: 400;">TEST-NET</span>
&nbsp;&nbsp;|&nbsp;&nbsp;
Expand Down
30 changes: 30 additions & 0 deletions interface/client/templates/elements/nodeInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@ var getPeerCount = function(template) {
});
};

/**
Update the mining hashrate
@method getMining
*/
var getMining = function(template) {
web3.eth.getMining(function(e, res) {
if(!e && res) {
web3.eth.getHashrate(function(e, res) {
if(!e) {
TemplateVar.set(template, 'mining', numeral(res/1000).format('0,0.000'));
}
});
} else {
TemplateVar.set(template, 'mining', false);
}
});
};

/**
The main template
Expand Down Expand Up @@ -79,6 +98,17 @@ Template['elements_nodeInfo'].onCreated(function(){
this.peerCountIntervalId = setInterval(function() {
getPeerCount(template);
}, 1000);

// CHECK MINING and HASHRATE
this.miningIntervalId = null;

TemplateVar.set('mining', false);
getMining(template);

Meteor.clearInterval(this.miningIntervalId);
this.miningIntervalId = setInterval(function() {
getMining(template);
}, 1000);
});


Expand Down
8 changes: 6 additions & 2 deletions modules/menuItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,17 +240,21 @@ var menuTempl = function(webviews) {
label: (global.mining) ? i18n.t('mist.applicationMenu.develop.stopMining') : i18n.t('mist.applicationMenu.develop.startMining'),
enabled: (global.network === 'test'),
click: function(){
// TODO remove on new RPC
if(!global.nodeConnector.socket.writable)
global.nodeConnector.connect();

if(!global.mining) {
global.nodeConnector.send('miner_start', [1], function(e, result){
console.log('miner_start', result);
console.log('miner_start', result, e);
if(result === true) {
global.mining = !global.mining;
createMenu(webviews);
}
});
} else {
global.nodeConnector.send('miner_stop', [], function(e, result){
console.log('miner_stop', result);
console.log('miner_stop', result, e);
if(result === true) {
global.mining = !global.mining;
createMenu(webviews);
Expand Down

0 comments on commit 1b764b7

Please sign in to comment.