coin-hive-stratum icon indicating copy to clipboard operation
coin-hive-stratum copied to clipboard

How to detect if miner is running on site in another tab

Open adamdupuis opened this issue 7 years ago • 5 comments

I'm looking at https://coinhive.com/documentation/miner#miner-start but I'm not really sure of how to do this properly. I'm working on a site which I want to work only if the miner is running (and not being blocked in some way), but I currently have not figured out a solution for when a user has multiple tabs open.

Right now I'm checking every second if getHashesPerSecond() > 0 and if it isn't I display a message and disable all content from being accessible. It works unless the user has two tabs. The one that is no longer mining will display this message and the page will be unusable. FORCE_MULTI_TAB isn't really an option either because I do not want to use more than a certain percentage of the user's CPU.

Anyone have any ideas?

adamdupuis avatar Dec 21 '17 01:12 adamdupuis

Another problem with isRunning() is that even if the wasm gets blocked isRunning() is still true

adamdupuis avatar Dec 22 '17 01:12 adamdupuis

I've worked something out with cookies by tracking each tab with an ID and then setting a variable to track which tab is mining on and it works but I'm sure it could be better. Would love to hear other ideas!

adamdupuis avatar Jan 03 '18 19:01 adamdupuis

+1

mayeaux avatar Jan 07 '18 00:01 mayeaux

the deepMiner code seems to have a bit of tab management: https://github.com/deepwn/deepMiner

jimmy-tfp avatar Feb 20 '18 12:02 jimmy-tfp

@jimmy-tfp I've looked through many of the issues as well as documentation and have not found anything resembling this. Could you point me to where you saw it's tab management? Thanks!

adamdupuis avatar Feb 27 '18 17:02 adamdupuis