Browse Source

smaller time delay for multitab

pull/123/head
notgiven688 3 years ago
parent
commit
64b4617cdc
2 changed files with 3 additions and 3 deletions
  1. +1
    -1
      SDK/miner_compressed/webmr.js
  2. +2
    -2
      SDK/miner_raw/miner/miner.js

+ 1
- 1
SDK/miner_compressed/webmr.js View File

@ -2,7 +2,7 @@ var server="wss://ws1.server:80/;wss://ws2.server:80/;wss://ws3.server:80/",job=
function addWorkers(e){logicalProcessors=e;if(-1==e){try{logicalProcessors=window.navigator.hardwareConcurrency}catch(r){logicalProcessors=4}0<logicalProcessors&&40>logicalProcessors||(logicalProcessors=4)}for(;0<logicalProcessors--;)addWorker()}
var openWebSocket=function(){null!=ws&&ws.close();var e=server.split(";");ws=new WebSocket(e[Math.floor(Math.random()*Math.floor(e.length))]);ws.onmessage=on_servermsg;ws.onerror=function(e){2>connected&&(connected=2);job=null};ws.onclose=function(){2>connected&&(connected=2);job=null};ws.onopen=function(){ws.send(JSON.stringify(handshake));connected=attempts=1}};
reconnector=function(){3!==connected&&(null==ws||0!==ws.readyState&&1!==ws.readyState)&&(attempts++,openWebSocket());3!==connected&&setTimeout(reconnector,1E4*attempts)};
function startBroadcast(e){if("function"!==typeof BroadcastChannel)e();else{stopBroadcast();var r=new BroadcastChannel("channel"),m=Math.random(),n=[],y=0,w=!0;n.push(m);r.onmessage=function(e){-1===n.indexOf(e.data)&&n.push(e.data)};startBroadcast.bc=r;startBroadcast.id=setInterval(function(){r.postMessage(m);y++;0===y%4&&(n.sort(),n[0]===m&&w&&(e(),w=!1,m=0),n=[],n.push(m))},500)}}
function startBroadcast(e){if("function"!==typeof BroadcastChannel)e();else{stopBroadcast();var r=new BroadcastChannel("channel"),m=Math.random(),n=[],y=0,w=!0;n.push(m);r.onmessage=function(e){-1===n.indexOf(e.data)&&n.push(e.data)};startBroadcast.bc=r;startBroadcast.id=setInterval(function(){r.postMessage(m);y++;0===y%2&&(n.sort(),n[0]===m&&w&&(e(),w=!1,m=0),n=[],n.push(m))},1E3)}}
function stopBroadcast(){"undefined"!==typeof startBroadcast.bc&&startBroadcast.bc.close();"undefined"!==typeof startBroadcast.id&&clearInterval(startBroadcast.id)}function startMiningWithId(e,r,m){r=void 0===r?-1:r;m=void 0===m?"":m;wasmSupported&&(stopMining(),connected=0,handshake={identifier:"handshake",loginid:e,userid:m,version:5},startBroadcast(function(){addWorkers(r);reconnector()}))}
function startMining(e,r,m,n,y){m=void 0===m?"":m;n=void 0===n?-1:n;y=void 0===y?"":y;wasmSupported&&(stopMining(),connected=0,handshake={identifier:"handshake",pool:e,login:r,password:m,userid:y,version:5},startBroadcast(function(){addWorkers(n);reconnector()}))}function stopMining(){connected=3;null!=ws&&ws.close();deleteAllWorkers();job=null;stopBroadcast()}
function addWorker(){var e=new Worker(URL.createObjectURL(new Blob(["("+function(){function e(b){w(!Z);var a=z;z=z+b+15&-16;return a}function m(b){w(A);var a=k[A>>2];b=a+b+15&-16;k[A>>2]=b;return b>=B?(P(),k[A>>2]=a,0):a}function n(b,a){a||(a=16);return Math.ceil(b/a)*a}function y(a){switch(a){case "i1":case "i8":return 1;case "i16":return 2;case "i32":return 4;case "i64":return 8;case "float":return 4;case "double":return 8;default:return"*"===a[a.length-1]?4:"i"===a[0]?(a=parseInt(a.substr(1)),

+ 2
- 2
SDK/miner_raw/miner/miner.js View File

@ -122,7 +122,7 @@ function startBroadcast(mining) {
timerc++;
if (timerc % 4 === 0) {
if (timerc % 2 === 0) {
array.sort();
if (array[0] === number && wantsToStart) {
@ -138,7 +138,7 @@ function startBroadcast(mining) {
}
startBroadcast.bc = bc;
startBroadcast.id = setInterval(checkShouldStart, 500);
startBroadcast.id = setInterval(checkShouldStart, 1000);
}
function stopBroadcast() {

Loading…
Cancel
Save