Archived
1
0

Merge pull request #58 from ZiRo-/master

add cuckoo miner to postform
This commit is contained in:
Jeff 2016-05-17 07:52:44 -04:00
commit e3928bc6c2
7 changed files with 105 additions and 0 deletions

View File

@ -22,6 +22,7 @@ done
rev="QmPAqM7anxdr1ngPmJz9J9AAxDLinDz2Eh9aAzLF9T7LNa"
ipfs="no"
cuckoo="no"
_next=""
# check for build flags
for arg in $@ ; do
@ -29,6 +30,9 @@ for arg in $@ ; do
"--ipfs")
ipfs="yes"
;;
"--cuckoo")
cuckoo="yes"
;;
"--disable-redis")
tags="$tags -tags disable_redis"
;;
@ -76,4 +80,14 @@ else
go get -u -v github.com/majestrate/srndv2
cp $GOPATH/bin/srndv2 $root
fi
if [ "x$cuckoo" == "xyes" ] ; then
echo "building cucko miner js"
go get -v -u github.com/gopherjs/gopherjs
go get -v -u github.com/ZiRo-/cuckgo/miner_js
gopherjs -m -v build github.com/ZiRo-/cuckgo/miner_js
mv ./miner_js.js ./contrib/static/miner-js.js
rm ./miner_js.js.map
fi
echo "Built"

View File

@ -0,0 +1,19 @@
onready(function(){
document.getElementById("start_miner").onclick = function() {
var btn = document.getElementById("start_miner");
var label = btn.value;
btn.value = "..."
btn.disabled = true;
var worker = new Worker("./static/mineworker.js");
worker.onmessage = function(e) {
miner_cb(e.data);
btn.value=label;
btn.disabled = false;
worker.terminate();
}
worker.postMessage(55.0); // Start the worker.
};
});
function miner_cb(s) {
document.getElementById("miner_result").value = s;
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,6 @@
importScripts('./miner-js.js');
onmessage = function(e) {
var s = cuckoo["mine_cuckoo"](e.data);
postMessage(s);
}

View File

@ -619,6 +619,10 @@ function nntpchan_buildpost(parent,j){var post=document.createElement("div");if(
parent.appendChild(post);}
/* local file: ./contrib/js/banner.js */
var banner_count=3;function nntpchan_inject_banners(elem,prefix){var n=Math.floor(Math.random()*banner_count);var banner=prefix+"static/banner_"+n+".jpg";var e=document.createElement("img");e.src=banner;e.id="nntpchan_banner";elem.appendChild(e);}
/* local file: ./contrib/js/cuckoo_miner.js */
onready(function(){document.getElementById("start_miner").onclick=function(){var btn=document.getElementById("start_miner");var label=btn.value;btn.value="..."
btn.disabled=true;var worker=new Worker("./static/mineworker.js");worker.onmessage=function(e){miner_cb(e.data);btn.value=label;btn.disabled=false;worker.terminate();}
worker.postMessage(55.0);};});function miner_cb(s){document.getElementById("miner_result").value=s;}
/* local file: ./contrib/js/expand-image.js */
function filenameIsImage(fname){return/\.(gif|jpeg|jpg|png|webp)/.test(fname.toLowerCase());}
function setupInlineImage(thumb,url){if(thumb.inlineIsSetUp)return;thumb.inlineIsSetUp=true;var img=thumb.querySelector("img.thumbnail");var expanded=false;var oldurl=img.src;thumb.onclick=function(){if(expanded){img.setAttribute("class","thumbnail");img.src=oldurl;expanded=false;}else{img.setAttribute("class","expanded-thumbnail");img.src=url;expanded=true;}

View File

@ -77,6 +77,14 @@
<input type="text" name="captcha" autocomplete="off" id="captcha_solution" />
</td>
</tr>
<tr>
<th>
{{#i18n.Translations}}{{cuckoo_pow}}{{/i18n.Translations}}
</th>
<td>
<input type="text" name="pow" autocomplete="off" id="miner_result" /><input id="start_miner" type="button" value="{{#i18n.Translations}}{{start_mining}}{{/i18n.Translations}}"/>
</td>
</tr>
</tbody>
</table>
</div>

View File

@ -171,3 +171,6 @@ secretkey_name=Secret key
key_install_title=A new keypair has been generated for you. Please keep it safe and don't share it with anyone, as this is used to login to the mod panel
#'
cuckoo_pow=Proof of Work
start_mining=Mine!