Bitcoin Forum
May 04, 2024, 01:26:39 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Code to check pool connection and connect elsewhere if down  (Read 3644 times)
TurdHurdur (OP)
Full Member
***
Offline Offline

Activity: 216
Merit: 100


View Profile
March 06, 2011, 11:21:52 AM
 #1

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 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.
1714785999
Hero Member
*
Offline Offline

Posts: 1714785999

View Profile Personal Message (Offline)

Ignore
1714785999
Reply with quote  #2

1714785999
Report to moderator
The trust scores you see are subjective; they will change depending on who you have in your trust list.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714785999
Hero Member
*
Offline Offline

Posts: 1714785999

View Profile Personal Message (Offline)

Ignore
1714785999
Reply with quote  #2

1714785999
Report to moderator
1714785999
Hero Member
*
Offline Offline

Posts: 1714785999

View Profile Personal Message (Offline)

Ignore
1714785999
Reply with quote  #2

1714785999
Report to moderator
1714785999
Hero Member
*
Offline Offline

Posts: 1714785999

View Profile Personal Message (Offline)

Ignore
1714785999
Reply with quote  #2

1714785999
Report to moderator
jgarzik
Legendary
*
Offline Offline

Activity: 1596
Merit: 1091


View Profile
March 06, 2011, 06:07:41 PM
 #2

Each miner should include code to fallback to a separate miner.

Jeff Garzik, Bloq CEO, former bitcoin core dev team; opinions are my own.
Visit bloq.com / metronome.io
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
dishwara
Legendary
*
Offline Offline

Activity: 1855
Merit: 1016



View Profile
March 06, 2011, 06:40:14 PM
 #3

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 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?
TurdHurdur (OP)
Full Member
***
Offline Offline

Activity: 216
Merit: 100


View Profile
March 06, 2011, 07:11:27 PM
 #4

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.
TurdHurdur (OP)
Full Member
***
Offline Offline

Activity: 216
Merit: 100


View Profile
March 07, 2011, 02:37:18 AM
 #5

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, 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.
Dude65535
Full Member
***
Offline Offline

Activity: 126
Merit: 101


View Profile
March 09, 2011, 04:57:17 AM
 #6

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.




1DCj8ZwGZXQqQhgv6eUEnWgsxo8BTMj3mT
dishwara
Legendary
*
Offline Offline

Activity: 1855
Merit: 1016



View Profile
May 04, 2011, 07:55:11 PM
 #7

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?
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!