Bitcoin Forum
December 10, 2016, 08:46:35 PM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: « 1 [2] 3 4 5 6 7 8 9 10 11 12 13 »  All
  Print  
Author Topic: Embedable Javascript Bitcoin miner for your website  (Read 131586 times)
1bitc0inplz
Member
**
Offline Offline

Activity: 112


View Profile
May 20, 2011, 03:55:30 AM
 #21

This is freakingly awesome idea!

It surely will help to better distribute the overall hashing power, thus making the bitcoin network even more resilient.


I'm not sure the client will be very happy to see his computer burn CPU for apparently no apparent reason, though.   Cheesy   But indeed it is probably better than annoying ads.   Again:  awesome idea.

Thanks, a lot. The encouragement means a lot. I agree, a lot of users and website operators may not like the idea that the CPU is worked so hard on some browsers. The underlying jsMiner engine supports an option of forcing the work to be done in the UI thread, and thusly in setTimeouts... this is VERY CPU friendly. If you compare the CPU usage that IE produces on bip.it versus Chrome you will see that IE appears to use very little CPU time where Chrome uses a whole core... this is the different between IE using the UI thread and Chrome using an HTML WebWorker.

Either way, I just made a feature request in our project tracker to get these underlying jsMiner settings exposed so that the end website operator can better tune their user's experience.

I'm probably about to show my ignorance of bitcoind and Javascript/HTML5 in a couple of lines (I'm a Java/C programmer and tend to ignore Javascript wholesale) but here I go.

Is it possible to push smaller work units than the default (most cpu's seem to do about 1 share per minute from my experience) in order to reduce the amount of time required on each page, or are the share sizes a hard coded part of bitcoind/rpc? Or perhaps is it possible to have the miner store its state in HTML 5's cache in some way, so that it can be resumed on subsequent pages? Or maybe make use of a cookie to store the state information which is then reread on the new page?

The typical "getwork" protocol that nearly every miner uses is very poor. The protocol hands a chunk of work to the client and says "here, go".. and the client just tries to go over the whole nonce range. This is a poor design for slower clients. We wrote a more RESTful protocol for fetching work, and in this protocol we also took the liberty of having the server tell the client which nonce ranges to loop over. This allows a server to better coordinate a hash search when it knows it has slower clients. This also eliminates the need for state as, by default, the browsers are only given enough work for about 30 seconds and will POST back their results immediately if a share is found.

Mine @ http://pool.bitp.it - No fees, virtually 0 stales, what's not to love!
Chat with us @ #bitp.it on irc.freenode.net
Learn more about our pool @ http://forum.bitcoin.org/index.php?topic=12181.0
1481402795
Hero Member
*
Offline Offline

Posts: 1481402795

View Profile Personal Message (Offline)

Ignore
1481402795
Reply with quote  #2

1481402795
Report to moderator
1481402795
Hero Member
*
Offline Offline

Posts: 1481402795

View Profile Personal Message (Offline)

Ignore
1481402795
Reply with quote  #2

1481402795
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1bitc0inplz
Member
**
Offline Offline

Activity: 112


View Profile
May 20, 2011, 03:57:50 AM
 #22

Edit: I'd like to make a request, I'm sure its already on the cards but I'll ask anyway, within the control panel it would be nice to see some information such as effective total hash rates, number of users currently hashing and such and perhaps some distinction between the pages which it is being run from (or some ability to set of "campaigns") so that we can see which pages on our websites are proving more or less effective that generating coins.

Thanks for the input. A control panel is in the works... but it means a lot more to us to hear specifics on what you guys are looking for. Specifics like you just listed help us a *lot*.


Keep the ideas coming.  Smiley

Mine @ http://pool.bitp.it - No fees, virtually 0 stales, what's not to love!
Chat with us @ #bitp.it on irc.freenode.net
Learn more about our pool @ http://forum.bitcoin.org/index.php?topic=12181.0
1bitc0inplz
Member
**
Offline Offline

Activity: 112


View Profile
May 20, 2011, 04:01:03 AM
 #23

I think I might have run into an issue with the API?

I have placed the code into the head location on my website and it works fine in Chrome V11, however when I attempt to load it in Firefox 4.0.1 it throws the following

Code:
"[04:22:30.707] Permission denied to access property 'bitpit_params' @ http://api.bitp.it/mine:5"


Ok... call me silly... but I just loaded bitp.it in Firefox 4.0.1 on my Mac, and it appears to be working just fine.

Judging from the IE 9 bug, is it safe to assume you're on Windows for Firefox too? I will boot up a VM and try it there as well.

Also, when you encountered this, were you hitting bitp.it directly, or were you trying to embed this onto your own website?

Sorry, I am just trying to reproduce this so I can fix it  Cheesy

Mine @ http://pool.bitp.it - No fees, virtually 0 stales, what's not to love!
Chat with us @ #bitp.it on irc.freenode.net
Learn more about our pool @ http://forum.bitcoin.org/index.php?topic=12181.0
Turix
Member
**
Offline Offline

Activity: 76



View Profile WWW
May 20, 2011, 04:08:08 AM
 #24

It is embedded on my own website all of the aforementioned browsers work fine when testing directly on bitp.it using Windows 7; I have also additionally tested it using Firefox Nightly 6a on an Ubuntu 11.04 machine and it is returning the same permission error.

Code block copied verbatim from the submit page:

Code:
<script type="text/javascript" src="http://api.bitp.it/bitp.it.js"></script>
<script type="text/javascript">
  bitpit({clientId: "36"});
</script>

Not a problem, I'm used to dealing with users who don't even understand how to use their Windows PC properly so I know your pain exactly  Lips sealed.

Edit: While testing this I have noticed what could be a fatal issue for some people (myself included), if you have two pages of the same website open in two separate tabs it causes the script to execute twice and runs the systems CPU up to the point where (In my case anyway) the computer became very unresponsive. Scratch that it seems fine between Firefox 4 tabs, the issue that actually caused my PC to freeze was having Chrome and Firefox both independently running a copy of the script.

I have also setup a completely stripped page on my website to demonstrate the permission issue away from the gunk of the SMF install, here.

Also another suggestion (I know, I'm a pain right?) perhaps give the webmaster more direct access the the jsMiner "engine" object so that we can easily pull information such as the hash rate?

YinCoin YangCoin ☯☯First Ever POS/POW Alternator! Multipool! ☯ ☯ http://yinyangpool.com/ 
Free Distribution! https://bitcointalk.org/index.php?topic=623937
Bwincoin - 100% Free POS. BSqnSwv7xdD6UEh8bJz8Xp6YcndPQ2JFyF
1bitc0inplz
Member
**
Offline Offline

Activity: 112


View Profile
May 20, 2011, 05:22:49 AM
 #25

It is embedded on my own website all of the aforementioned browsers work fine when testing directly on bitp.it using Windows 7; I have also additionally tested it using Firefox Nightly 6a on an Ubuntu 11.04 machine and it is returning the same permission error.

Code block copied verbatim from the submit page:

Code:
<script type="text/javascript" src="http://api.bitp.it/bitp.it.js"></script>
<script type="text/javascript">
  bitpit({clientId: "36"});
</script>

Not a problem, I'm used to dealing with users who don't even understand how to use their Windows PC properly so I know your pain exactly  Lips sealed.

Edit: While testing this I have noticed what could be a fatal issue for some people (myself included), if you have two pages of the same website open in two separate tabs it causes the script to execute twice and runs the systems CPU up to the point where (In my case anyway) the computer became very unresponsive. Scratch that it seems fine between Firefox 4 tabs, the issue that actually caused my PC to freeze was having Chrome and Firefox both independently running a copy of the script.

I have also setup a completely stripped page on my website to demonstrate the permission issue away from the gunk of the SMF install, here.

Also another suggestion (I know, I'm a pain right?) perhaps give the webmaster more direct access the the jsMiner "engine" object so that we can easily pull information such as the hash rate?

Thanks for helping identify the issue. It turns out that the way we were passing parameters into the iframe was not cross domain compliant for all browsers. We've instead resorted to passing them via the iframe's src URL as query strings. Nothing will change on your end, except the code will just start working

This also should all you to specify more custom jsMiner engine settings. I will work on getting that list together of what can be tweaked and post back up. For one you can specify the forceUIThread: true in your params... so your code might look like:
Code:
<script type="text/javascript" src="http://api.bitp.it/bitp.it.js"></script>
<script type="text/javascript">
bitpit({clientId: "ID", forceUIThread: true});
</script>

Forcing the UI thread will limit the CPU usage by causing the miner to be more friendly for browsers that do not support HTML 5 WebWorkers... I added it as more of a debugging setting, but there is no harm in forcing all your visitors miners to be more friendly (except a lower hash rate).

There are more settings, but I will need to dig into that part of the source and make a list of what all they do.


As far as getting info out of the miner... that might not be an easy thing. I will need to ponder on that some more. The complication is that the miner, due to cross domain issues, lives in an iframe. Your website will not be able to just talk directly to that JS object... we could pass info back by modifying the iframe src URL (similar to what we are doing to pass info in), but unlike inbound parameters, if we used hash tags that should work...

Mine @ http://pool.bitp.it - No fees, virtually 0 stales, what's not to love!
Chat with us @ #bitp.it on irc.freenode.net
Learn more about our pool @ http://forum.bitcoin.org/index.php?topic=12181.0
gjs278
Jr. Member
*
Offline Offline

Activity: 33


View Profile
May 20, 2011, 07:49:19 AM
 #26

I've embedded it on my website, should receive about 10k hits a day. it would definitely be cool to get those registration emails out there so I can see stats, this is a great idea.
will
Full Member
***
Offline Offline

Activity: 176



View Profile
May 20, 2011, 07:54:31 AM
 #27

Great idea, I will support this in any way I can.

I'm working on a gaming website which allows players to compete in sit-down tournaments for BTC and this would be perfect to include on that. You should also look into using accessing the GPU for the calcs.
Maybe something like WebCL: http://webcl.nokiaresearch.com/index.html

If you can get this working it's be awesome.
caveden
Legendary
*
Offline Offline

Activity: 1106



View Profile
May 20, 2011, 08:04:34 AM
 #28

This is really powerful.

A question: is the mining task correctly prioritized not to annoy the user (lower priority than anything else)?
The CPU going to 100% won't be a problem if the user continues to be able to use his computer normally. But if the mining process has the same priority as other user processes, that might piss him off, with reason.
I don't even know if you can set priorities in javascript like that.

18rZYyWcafwD86xvLrfuxWG5xEMMWUtVkL
robmon
Newbie
*
Offline Offline

Activity: 12


View Profile
May 20, 2011, 09:12:43 AM
 #29

I just have to say that this is pure brilliance!

This changes everything. How long before we no longer can browse the Internet without CPU spiking to 100%?   Cheesy
PIO
Newbie
*
Offline Offline

Activity: 27


View Profile
May 20, 2011, 09:33:45 AM
 #30

I see one BIG flaw on this system... google its gona kill you.

They gona mark the web page as a "malware".

You could easily hide it from bots with a few lines of PHP.
gumbah
Newbie
*
Offline Offline

Activity: 2


View Profile
May 20, 2011, 09:41:36 AM
 #31

This is awesome! I've added the code to http://randomgam.es to try out.

First impression (on a relatively new MB pro) is that the machine's fans are going nuts when leaving the page open for a while... (this is the case in both firefox and chrome). Anyone else experiencing this?
pindis
Full Member
***
Offline Offline

Activity: 150



View Profile
May 20, 2011, 09:48:34 AM
 #32

This is awesome! I've added the code to http://randomgam.es to try out.

First impression (on a relatively new MB pro) is that the machine's fans are going nuts when leaving the page open for a while... (this is the case in both firefox and chrome). Anyone else experiencing this?

That's kind of obvious isn't it? since it's using cpu, hence the cpu gets warmer which leads to more RPM cycles?

Donations:
LTC: LL6DznTetC6Xi6YZtLsYQ9QPoxFfoRcNx2 BTC: 1HNUCrSPQ3b8fTnZiZgFTDisnbNuSxwdRc XPM: AQS7ttCZXFU4HUTFo8BmB4wrAfb8NxSuJF
gumbah
Newbie
*
Offline Offline

Activity: 2


View Profile
May 20, 2011, 09:53:37 AM
 #33

This is awesome! I've added the code to http://randomgam.es to try out.

First impression (on a relatively new MB pro) is that the machine's fans are going nuts when leaving the page open for a while... (this is the case in both firefox and chrome). Anyone else experiencing this?

That's kind of obvious isn't it? since it's using cpu, hence the cpu gets warmer which leads to more RPM cycles?

It's obvious why it's happening, but shouldn't it be using just enough cpu so that the visitors/users of the site don't notice anything?
gigabytecoin
Sr. Member
****
Offline Offline

Activity: 280


View Profile
May 20, 2011, 10:35:59 AM
 #34

This is freakingly awesome idea!

It surely will help to better distribute the overall hashing power, thus making the bitcoin network even more resilient.


I'm not sure the client will be very happy to see his computer burning CPU for  no apparent reason, though.   Cheesy   But indeed it is probably better than annoying ads.   Again:  awesome idea.

Not quite...

Google could place this on their website and gain 50%+ hashing power of the network overnight.

EDIT: Then again, maybe not...

According to my calculations....

One $100 5830 can do 300,000,000 hashes per second if tweaked correctly.

Divided by an average of 10,000 hashes per second for an average cpu running this javascript miner = 30,000 concurrent visitors to your website to equal the hashing power of a 5830 - and whenever users hit your website, their CPUs would start burning up... so they would probably leave within let's say 2 minutes of visiting your web page.

So multiply 30,000 concurrent required visitors by the number of 2 minute intervals in the day... (24 * 60 / 2 = 720)

And you come to a total of 21,600,000 unique visitors per day that you would need to your website in order to hash the equivalent of a $100 GPU.

Or make about $8 per day according to the bitcoin calculator right now from 21 million unique visitors.... totally not worth it.

Phew, now I feel better about my mining investments!

Don't get me wrong OP, I love it when anybody contributes anything to the bitcoin network, I am just thinking out loud.
Soepkip
Sr. Member
****
Offline Offline

Activity: 378


View Profile
May 20, 2011, 11:53:23 AM
 #35

Just awesome. An easy way to use my work computer as a bitcoin generator. I can even leave it on 24/7 if the cleaning lady doesn't turn it off Wink.

Any easy way for me to display my hashes/s in the little HTML file i made?

Also: When running one instance i get 50% CPU, with two 100% CPU. Does this matter in the sense that i might be doing double work or?



SHADOW
███████████████
██████████████████
████████████████████
██████████████████████
████████████████████████
████████████████████████
████████████████████████
████████████████████████
████████████████████████
████████████████████████
████████████████████████
██████████████████████
████████████████████
██████████████████
███████████████
.

.

.

.

╔══SHADOW.HOME.PAGE
╠═SHADOW.FORUM
SHADOW.WIKI
1bitc0inplz
Member
**
Offline Offline

Activity: 112


View Profile
May 20, 2011, 12:43:23 PM
 #36

Wow!

First off, to everyone who registered and/or replied to this thread. Thank you all. I never imagined there would be this much interest in this. Your feedback, all of it, is great. This is really helping us find ways to make this even better.

I see one BIG flaw on this system... google its gona kill you.

They gona mark the web page as a "malware".

You could easily hide it from bots with a few lines of PHP.

I am a little confused on what the concern is. AFAIK, Google, et al, do not execute Javascript when they visit your website. Am I missing something?

This is really powerful.

A question: is the mining task correctly prioritized not to annoy the user (lower priority than anything else)?
The CPU going to 100% won't be a problem if the user continues to be able to use his computer normally. But if the mining process has the same priority as other user processes, that might piss him off, with reason.
I don't even know if you can set priorities in javascript like that.

Javascript cannot explicitly set thread prioritization, the browser is left taking care of that. From my testing, it would appear that all the major browsers do set thread priority to "nice". Read my replies below though, because this seems to be a shared concern, and I think I know how we can help limit the CPU utilization if you so desired.


This is freakingly awesome idea!

It surely will help to better distribute the overall hashing power, thus making the bitcoin network even more resilient.


I'm not sure the client will be very happy to see his computer burning CPU for  no apparent reason, though.   Cheesy   But indeed it is probably better than annoying ads.   Again:  awesome idea.

Not quite...

Google could place this on their website and gain 50%+ hashing power of the network overnight.

EDIT: Then again, maybe not...

According to my calculations....

One $100 5830 can do 300,000,000 hashes per second if tweaked correctly.

Divided by an average of 10,000 hashes per second for an average cpu running this javascript miner = 30,000 concurrent visitors to your website to equal the hashing power of a 5830 - and whenever users hit your website, their CPUs would start burning up... so they would probably leave within let's say 2 minutes of visiting your web page.

So multiply 30,000 concurrent required visitors by the number of 2 minute intervals in the day... (24 * 60 / 2 = 720)

And you come to a total of 21,600,000 unique visitors per day that you would need to your website in order to hash the equivalent of a $100 GPU.

Or make about $8 per day according to the bitcoin calculator right now from 21 million unique visitors.... totally not worth it.

Phew, now I feel better about my mining investments!

Don't get me wrong OP, I love it when anybody contributes anything to the bitcoin network, I am just thinking out loud.

Thanks, I appreciate the feedback. You are right, this is not ever going to compete with a GPU miner. The basic idea is that you, the website operator, have all these visitors. Right now many websites place banner ads on their site to try and make revenue. Banner ads are less than ideal in that they require the visitor to do something (assuming PPC, not PPV) for you to make revenue. This, however, is entirely non-volontary on the site visitor's behalve. They *have* to mine bitcoins for you if they are using your site. There was mention in a previous reply about turning this off for registered users, or other sub-sections of your website base, and I think thats an awesome idea too.

Where this Javascript miner really shines is in it hash/sec per watt  Cheesy

I do think you have a valid point about not wanting to run people off with a high CPU usage, so did a few others. For now, just use the forceUIThread: true setting to make the worker process more CPU friendly. This will reduce your hashing rate, but will make it more friendly for your website visitors if you choose. Today I will also look into making more of a "nice" setting where you could set the niceness with better precession... of course this would be implemented in a work-pause-work, and not actually setting the thread priority level... but, I do believe the browsers already have their threads set to nice... so this would only be reducing the CPU load, which is what I believe you (all) are looking for as an option. I agree, I think that'd be a good setting to have.

As far as GPUs, I'm glad I bought mine as well. I do not think they'll be going anywhere anytime soon.

Just awesome. An easy way to use my work computer as a bitcoin generator. I can even leave it on 24/7 if the cleaning lady doesn't turn it off Wink.

Any easy way for me to display my hashes/s in the little HTML file i made?

Also: When running one instance i get 50% CPU, with two 100% CPU. Does this matter in the sense that i might be doing double work or?

Which browser gave you 100%? Of the browsers I tested, they generally fall into two categories... those that support HTML 5 web workers, and those that do not. Only the ones that support web workers should be running the CPU at any noticeable percent (maybe I'm wrong, I'll test more)... but the ones with web workers support will max out 1 core.

So, in the 50% case, I assume that means you have a dual-core machine?

In the 100% case.... I am stumped. Unless you only had 1 core, or had this open in multiple tabs, I do not know how that would have happened. Let me know what browser and OS, and I'll look into it.

Mine @ http://pool.bitp.it - No fees, virtually 0 stales, what's not to love!
Chat with us @ #bitp.it on irc.freenode.net
Learn more about our pool @ http://forum.bitcoin.org/index.php?topic=12181.0
ChaosFox
Full Member
***
Offline Offline

Activity: 172


Certified fox posing as a cat posing as a human


View Profile WWW
May 20, 2011, 01:09:36 PM
 #37

Hmm, interesting.  Grin Patiently waiting for a full release. One thing that I'd like to know, though. I accidentally signed up several times, and I believe my ID's were different for each. While the control panel thingamabob isn't working yet, which ID should I use with the embedded code? The last one I got?

If you liked what I said: 1Chaosb1cafG3RYPhdFF8BMmQHZuuxmJY

The Fading Fox
Soepkip
Sr. Member
****
Offline Offline

Activity: 378


View Profile
May 20, 2011, 01:35:49 PM
 #38

Wow!

Just awesome. An easy way to use my work computer as a bitcoin generator. I can even leave it on 24/7 if the cleaning lady doesn't turn it off Wink.

Any easy way for me to display my hashes/s in the little HTML file i made?

Also: When running one instance i get 50% CPU, with two 100% CPU. Does this matter in the sense that i might be doing double work or?

Which browser gave you 100%? Of the browsers I tested, they generally fall into two categories... those that support HTML 5 web workers, and those that do not. Only the ones that support web workers should be running the CPU at any noticeable percent (maybe I'm wrong, I'll test more)... but the ones with web workers support will max out 1 core.

So, in the 50% case, I assume that means you have a dual-core machine?

In the 100% case.... I am stumped. Unless you only had 1 core, or had this open in multiple tabs, I do not know how that would have happened. Let me know what browser and OS, and I'll look into it.

I have dual core. With one tab open it goes to 50% CPU. With two tabs open to 100% CPU. So that works fine. However, i want to know if i'm working on 2 different shares in that sense. Offcourse using Chrome.

Also, how do i easily show hashes/s just like bitp.it does?

SHADOW
███████████████
██████████████████
████████████████████
██████████████████████
████████████████████████
████████████████████████
████████████████████████
████████████████████████
████████████████████████
████████████████████████
████████████████████████
██████████████████████
████████████████████
██████████████████
███████████████
.

.

.

.

╔══SHADOW.HOME.PAGE
╠═SHADOW.FORUM
SHADOW.WIKI
JohnDoe
Sr. Member
****
Offline Offline

Activity: 392



View Profile
May 20, 2011, 02:08:09 PM
 #39

This is pretty damn cool.

Is there no way to add GPU mining to this?

EDIT: To answer my own question, it looks like it would be possible in the future using WebCL.
Turix
Member
**
Offline Offline

Activity: 76



View Profile WWW
May 20, 2011, 02:50:10 PM
 #40

When comparing the effects of using forceUIThread / webWorkers I noticed that the UIThread variant makes a lot more requests to the server than the webWorker variant. webWorker seems to make about 1 request every 10seconds in FF4, whereas UIThread appears to be making 5 or more requests a second.

Just want to confirm that this is the intended behavior.

YinCoin YangCoin ☯☯First Ever POS/POW Alternator! Multipool! ☯ ☯ http://yinyangpool.com/ 
Free Distribution! https://bitcointalk.org/index.php?topic=623937
Bwincoin - 100% Free POS. BSqnSwv7xdD6UEh8bJz8Xp6YcndPQ2JFyF
Pages: « 1 [2] 3 4 5 6 7 8 9 10 11 12 13 »  All
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!