Skip to content
Newer
Older
100755 74 lines (60 sloc) 3.88 KB
343abc9 @m0mchil initial
m0mchil authored Oct 4, 2010
1 #!/usr/bin/python
2
f209170 @m0mchil using brocktice's BitcoinMiner, added time update every second, remov…
m0mchil authored Dec 7, 2010
3 from BitcoinMiner import *
d20b141 @m0mchil initial work on transport separation
m0mchil authored Jul 14, 2011
4 from optparse import OptionGroup, OptionParser
5 from time import sleep
6 import HttpTransport
7 import pyopencl as cl
8 import socket
9
10 # Socket wrapper to enable socket.TCP_NODELAY and KEEPALIVE
11 realsocket = socket.socket
12 def socketwrap(family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0):
13 sockobj = realsocket(family, type, proto)
14 sockobj.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
15 sockobj.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
16 return sockobj
17 socket.socket = socketwrap
18
19 VERSION = '20110709'
006fee5 @m0mchil added option for vectors usage
m0mchil authored Nov 2, 2010
20
a581a24 @gominoa Updated help to reflect server#tag
gominoa authored Jul 8, 2011
21 usage = "usage: %prog [OPTION]... SERVER[#tag]...\nSERVER is one or more [http[s]://]user:pass@host:port (required)\n[#tag] is a per SERVER user friendly name displayed in stats (optional)"
d20b141 @m0mchil initial work on transport separation
m0mchil authored Jul 14, 2011
22 parser = OptionParser(version=VERSION, usage=usage)
7942f75 @m0mchil passing whole options
m0mchil authored Jul 1, 2011
23 parser.add_option('--verbose', dest='verbose', action='store_true', help='verbose output, suitable for redirection to log file')
88eb0db @gominoa Add --quiet option; suppress all output except hash rate display
gominoa authored Jul 8, 2011
24 parser.add_option('-q', '--quiet', dest='quiet', action='store_true', help='suppress all output except hash rate display')
ab0be37 @gominoa cleaned up OptionParser, moved --servers to positional args
gominoa authored Jul 8, 2011
25
26 group = OptionGroup(parser, "Miner Options")
9d57272 @m0mchil changed primary pool default retry interval to 10 getworks
m0mchil authored Jul 8, 2011
27 group.add_option('-r', '--rate', dest='rate', default=1, help='hash rate display interval in seconds, default=1', type='float')
28 group.add_option('-e', '--estimate', dest='estimate', default=900, help='estimated rate time window in seconds, default 900 (15 minutes)', type='int')
29 group.add_option('-a', '--askrate', dest='askrate', default=5, help='how many seconds between getwork requests, default 5, max 10', type='int')
30 group.add_option('-t', '--tolerance', dest='tolerance', default=2, help='use fallback pool only after N consecutive connection errors, default 2', type='int')
b1202bb @m0mchil proper help message fro default failback counter
m0mchil authored Jul 14, 2011
31 group.add_option('-b', '--failback', dest='failback', default=10, help='attempt to fail back to the primary pool every N getworks, default 10', type='int')
af4bd3e @m0mchil added option for disabling server-provided failbacks
m0mchil authored Jul 9, 2011
32 parser.add_option('--no-server-failbacks', dest='nsf', action='store_true', help='disable using failback hosts provided by server')
ab0be37 @gominoa cleaned up OptionParser, moved --servers to positional args
gominoa authored Jul 8, 2011
33 parser.add_option_group(group)
34
35 group = OptionGroup(parser, "Kernel Options")
9d57272 @m0mchil changed primary pool default retry interval to 10 getworks
m0mchil authored Jul 8, 2011
36 group.add_option('-p', '--platform', dest='platform', default=-1, help='use platform by id', type='int')
ab0be37 @gominoa cleaned up OptionParser, moved --servers to positional args
gominoa authored Jul 8, 2011
37 group.add_option('-d', '--device', dest='device', default=-1, help='use device by id, by default asks for device', type='int')
38 group.add_option('-w', '--worksize', dest='worksize', default=-1, help='work group size, default is maximum returned by opencl', type='int')
39 group.add_option('-f', '--frames', dest='frames', default=30, help='will try to bring single kernel execution to 1/frames seconds, default=30, increase this for less desktop lag', type='int')
40 group.add_option('-s', '--sleep', dest='frameSleep', default=0, help='sleep per frame in seconds, default 0', type='float')
41 group.add_option('-v', '--vectors', dest='vectors', action='store_true', help='use vectors')
42 parser.add_option_group(group)
43
45ec0f8 @gominoa Cleaned up options.servers, pass array instead of build string and split
gominoa authored Jul 8, 2011
44 (options, options.servers) = parser.parse_args()
ab0be37 @gominoa cleaned up OptionParser, moved --servers to positional args
gominoa authored Jul 8, 2011
45
343abc9 @m0mchil initial
m0mchil authored Oct 4, 2010
46
da70943 @m0mchil support for more than one OpenCL platform
m0mchil authored Feb 22, 2011
47 platforms = cl.get_platforms()
2f1c31a @m0mchil auto adjusting global threads to a sane value (thanks Diablo-D3)
m0mchil authored Oct 5, 2010
48
da70943 @m0mchil support for more than one OpenCL platform
m0mchil authored Feb 22, 2011
49 if options.platform >= len(platforms) or (options.platform == -1 and len(platforms) > 1):
50 print 'Wrong platform or more than one OpenCL platforms found, use --platform to select one of the following\n'
51 for i in xrange(len(platforms)):
52 print '[%d]\t%s' % (i, platforms[i].name)
53 sys.exit()
54
55 if options.platform == -1:
56 options.platform = 0
57
58 devices = platforms[options.platform].get_devices()
f209170 @m0mchil using brocktice's BitcoinMiner, added time update every second, remov…
m0mchil authored Dec 7, 2010
59 if (options.device == -1 or options.device >= len(devices)):
60 print 'No device specified or device not found, use -d to specify one of the following\n'
61 for i in xrange(len(devices)):
62 print '[%d]\t%s' % (i, devices[i].name)
63 sys.exit()
2f1c31a @m0mchil auto adjusting global threads to a sane value (thanks Diablo-D3)
m0mchil authored Oct 5, 2010
64
2f2f52d @m0mchil better ctrl-C handling
m0mchil authored Mar 2, 2011
65 miner = None
66 try:
d20b141 @m0mchil initial work on transport separation
m0mchil authored Jul 14, 2011
67 miner = BitcoinMiner(devices[options.device], options, VERSION, HttpTransport.HttpTransport)
68 miner.start()
2f2f52d @m0mchil better ctrl-C handling
m0mchil authored Mar 2, 2011
69 except KeyboardInterrupt:
70 print '\nbye'
71 finally:
d20b141 @m0mchil initial work on transport separation
m0mchil authored Jul 14, 2011
72 if miner: miner.stop()
e33761e @kylegibson backup
kylegibson authored May 31, 2011
73 sleep(1.1)
Something went wrong with that request. Please try again.