Bitcoin Forum

Bitcoin => Mining => Topic started by: TurdHurdur on March 06, 2011, 11:21:52 AM



Title: Code to check pool connection and connect elsewhere if down
Post by: TurdHurdur on March 06, 2011, 11:21:52 AM
I've come up with some Perl to handle when a miner loses its connection to a pool and switch to another pool/local bitcoind retrying every so many seconds(30 by default): http://pastebin.com/DhJeDmFV

It requires POE from CPAN, perhaps other modules depending on your Perl distribution.
Run it with no arguments or -h/--help for detailed and important usage info.

I've tested it out with a few miners, poclbm an ufasoft's miner work well, jgarzik's doesn't work so well, but can be made to work on Linux with a --conduit pty-pipe argument which requires IO::Pty from CPAN.

Here are a couple examples of connecting to [Tycho]'s pool (http://bitcointalk.org/index.php?topic=3889.0) and if it can't be connected to, connect to a local bitcoind:
Code:
perl miner_connect.pl -c "poclbm.exe --host=deepbit.net --port=8332 --user=username --pass=passwerd --device=0" -f "poclbm.exe --user=localuser --pass=localpass --device=0" --stream

Code:
perl miner_connect.pl -c "bitcoin-miner.exe -a 5 -t 1 -o http://deepbit.net:8332/ -u username -p password" -f "bitcoin-miner.exe -a 5 -t 1 -o http://localhost:8332/ -u localuser -p localpass" --stream

Hope it's useful. Feel free to ask comments/questions and modify the code to your liking.


Title: Re: Code to check pool connection and connect elsewhere if down
Post by: jgarzik on March 06, 2011, 06:07:41 PM
Each miner should include code to fallback to a separate miner.


Title: Re: Code to check pool connection and connect elsewhere if down
Post by: dishwara on March 06, 2011, 06:40:14 PM
I've come up with some Perl to handle when a miner loses its connection to a pool and switch to another pool/local bitcoind retrying every so many seconds(30 by default): http://pastebin.com/DhJeDmFV

It requires POE from CPAN, perhaps other modules depending on your Perl distribution.
Run it with no arguments or -h/--help for detailed and important usage info.

I've tested it out with a few miners, poclbm an ufasoft's miner work well, jgarzik's doesn't work so well, but can be made to work on Linux with a --conduit pty-pipe argument which requires IO::Pty from CPAN.

Here are a couple examples of connecting to [Tycho]'s pool (http://bitcointalk.org/index.php?topic=3889.0) and if it can't be connected to, connect to a local bitcoind:
Code:
perl miner_connect.pl -c "poclbm.exe --host=deepbit.net --port=8332 --user=username --pass=passwerd --device=0" -f "poclbm.exe --user=localuser --pass=localpass --device=0" --stream

Code:
perl miner_connect.pl -c "bitcoin-miner.exe -a 5 -t 1 -o http://deepbit.net:8332/ -u username -p password" -f "bitcoin-miner.exe -a 5 -t 1 -o http://localhost:8332/ -u localuser -p localpass" --stream

Hope it's useful. Feel free to ask comments/questions and modify the code to your liking.

Can u please explain, how to do it in windows & cmd prompt. Also what needs to be downloaded besides miners?


Title: Re: Code to check pool connection and connect elsewhere if down
Post by: TurdHurdur on March 06, 2011, 07:11:27 PM
Each miner should include code to fallback to a separate miner.
That'd be nice, but I don't know if each miner's creator would feel like doing that.

Can u please explain, how to do it in windows & cmd prompt. Also what needs to be downloaded besides miners?
Download and install Perl from http://strawberryperl.com/ I used 5.12 x86. The installer complained a bit, but everything was fine.

Run the CPAN Client, you can type it into the search field after pressing Start/Windows button. Or run cmd.exe and type cpan, hit enter.

From the cpan prompt, type
install POE
if there's one failed test(which I got), you can type
notest install POE
then type exit, and hit Enter.

Everything should work fine after that so long as you input the right -c and -f arguments.


Title: Re: Code to check pool connection and connect elsewhere if down
Post by: TurdHurdur on March 07, 2011, 02:37:18 AM
Actually, to expand on that, you need to install Win32::Console and Win32::Job via ppm:
ppm install Win32::Console Win32::Job
from the commandline.

When installing POE via cpan, you may fail 1-3 tests which don't seem the effect the usability of the script, so do a
notest install POE
in cpan.


The script also works with Activestate's Perl distro ActivePerl (http://www.activestate.com/activeperl/downloads), I tried the x86 version but it could work with the x86_64 version.

Installing POE using ActivePerl requires the command line:
ppm install POE
perhaps you'd find that easier.


Title: Re: Code to check pool connection and connect elsewhere if down
Post by: Dude65535 on March 09, 2011, 04:57:17 AM
I use a simpler but clumsier method for about the same effect. I run 2 copies of poclbm one with -f 60 connected to a mining pool and one with -f 300 solo mining.

The combined hash rate is about the same and the second copy immediately picks up any slack if there is a network hiccup.  The rest of the time the second copy gets about 6-7% of the gpu power.





Title: Re: Code to check pool connection and connect elsewhere if down
Post by: dishwara on May 04, 2011, 07:55:11 PM
Each miner should include code to fallback to a separate miner.
That'd be nice, but I don't know if each miner's creator would feel like doing that.

Can u please explain, how to do it in windows & cmd prompt. Also what needs to be downloaded besides miners?
Download and install Perl from http://strawberryperl.com/ I used 5.12 x86. The installer complained a bit, but everything was fine.

Run the CPAN Client, you can type it into the search field after pressing Start/Windows button. Or run cmd.exe and type cpan, hit enter.

From the cpan prompt, type
install POE
if there's one failed test(which I got), you can type
notest install POE
then type exit, and hit Enter.

Everything should work fine after that so long as you input the right -c and -f arguments.

I did as u said & also went to site & downloaded DhJeDmFV.txt & rename it to miner_connect.pl
& put the file in C:\strawberry\perl\bin folder. Then created batch file with this & ran it & got this error.

perl miner_connect.pl -c "C:\Users\Administrator\Desktop\poclbm_py2exe_20110428\poclbm.exe -d0 -v
-w128 -f10 --host=deepbit.net --port=8332 --user=username --pass=paswword --device=0"
-f "C:\Users\Administrator\Desktop\poclbm_py2exe_20110428\poclbm.exe -d0 -v -w128 -f1 --
host=mining.bitcoin.cz --port=8332 --user=username --pass=password" --stream

Can't locate POE.pm in @INC (@INC contains: C:/strawberry/perl/site/lib C:/straw
berry/perl/vendor/lib C:/strawberry/perl/lib .) at miner_connect.pl line 10.
BEGIN failed--compilation aborted at miner_connect.pl line 10.

username & password, i changed here for security.

what is the problem?
How to solve it?