1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-01 18:55:36 +00:00
Commit Graph

471 Commits

Author SHA1 Message Date
Con Kolivas
7d448cd754 timeGetTime uses huge resources on windows so revert to using timevals for its implementation of cgtimer_t 2013-08-19 23:39:49 +10:00
Con Kolivas
0414bf0960 Quotient/remainder error in ms division. 2013-08-19 21:36:00 +10:00
Con Kolivas
b238139cf9 Provide cgtimer_to_timeval helper functions. 2013-08-19 17:44:45 +10:00
Con Kolivas
09679e9f8b Provide a timeval_to_cgtime helper function to reuse values. 2013-08-19 17:38:20 +10:00
Con Kolivas
09e9091dd7 Simplify cgsleep code for windows by using a typedef for cgtimer_t that resolves to clock resolution, using that internally. 2013-08-19 13:54:56 +10:00
Con Kolivas
404cbdea84 On windows use the higher accuracy timegettime function to really get 1ms clock and timer accuracy. 2013-08-19 13:29:23 +10:00
Con Kolivas
ffa12a138a Fix missed endtimeperiod in overrun timer on windows. 2013-08-18 14:39:26 +10:00
Con Kolivas
ad87db07d9 Make cgsleep_us_r take an int64_t for us. 2013-08-18 14:39:26 +10:00
Con Kolivas
703c7309c2 Make the cgsleep functions build on windows. 2013-08-18 14:39:26 +10:00
Con Kolivas
8114473228 Set high resolution timing on windows within the cgsleep functions. 2013-08-18 11:39:09 +10:00
Con Kolivas
621eb00309 Provide reentrant versions of cgsleep functions to allow start time to be set separately from the beginning of the actual sleep, allowing scheduling delays to be counted in the sleep. 2013-08-18 10:49:52 +10:00
Con Kolivas
0b5edb24f9 Make the nmsleep and nusleep functions use the new cgsleep functions internally till functions are migrated to the new cgsleep API. 2013-08-18 10:36:25 +10:00
Con Kolivas
188210a3d2 Add a ms_to_timespec helper function, and create a cgsleep_ms function that uses absolute timers with clock_nanosleep to avoid overruns. 2013-08-18 10:28:28 +10:00
Con Kolivas
99cbf09dd1 Add a timeraddspec helper function. 2013-08-18 00:38:29 +10:00
Con Kolivas
1bcd9a43b1 Provide a us_to_timespec helper function. 2013-08-18 00:34:01 +10:00
Con Kolivas
2278204ddd Provide a us_to_timeval helper function. 2013-08-18 00:27:33 +10:00
Con Kolivas
a6b1c31742 Add helper functions to convert timespec to timeval and vice versa. 2013-08-18 00:19:47 +10:00
Con Kolivas
e95ad0479f Nonce2 stratum submission is not working with nonce2 lengths >4, revert the buggy __bin2hex function and use bin2hex. 2013-08-13 22:44:22 +10:00
Con Kolivas
87ae66c7e6 Create a work data template when receiving stratum notification, allowing a simple memcpy of the merkle root avoiding more hex2bin conversions on each work generation. 2013-08-13 05:49:32 +10:00
Con Kolivas
46b6b07afa Avoid a potential overflow should a pool specify a large nonce2 length with stratum. 2013-08-12 16:02:20 +10:00
Con Kolivas
5237bf350d Perform merkle bin hex2bin on stratum notify to avoid doing it on each work generation. 2013-08-12 11:36:28 +10:00
Con Kolivas
8bc469e916 Reuse just the one pool coinbase variable in stratum, avoiding more string functions and storage in gen_stratum_work on each work generation. 2013-08-12 11:16:46 +10:00
Con Kolivas
c542e47aa3 Use a nonce2 offset variable for both gbt and stratum to consolidate requirements on work generation. 2013-08-12 10:49:38 +10:00
Kano
eca6ace2d5 util.c update quit call for new functions 2013-08-12 09:00:52 +10:00
Kano
bab9ba9603 use correct define for OSX in util.c 2013-08-12 08:58:20 +10:00
Kano
bd3612c104 util.c expand quit to show file/func/line 2013-08-12 08:38:02 +10:00
Kano
cf30053793 Merge remote-tracking branch 'conman/master' 2013-08-12 08:35:29 +10:00
Con Kolivas
b423fe9de8 Cache the hex2bin of pool nonce1 in stratum, avoiding hex2bin on each work generation. 2013-08-11 14:06:17 +10:00
Con Kolivas
fef649dfef Cache the binary generation of coinbase1 and 2 on stratum, avoiding a hex2bin of coinbase1 and 2 on each work generation. 2013-08-11 13:47:46 +10:00
Kano
48d91c7f2d cgsem - increase information on failure 2013-08-10 10:36:38 +10:00
ckolivas
eb9278ca53 Check for negative wait time in socket_full. 2013-07-19 19:32:57 +10:00
ckolivas
f2ae7fadb2 Adjust socket wait timeout in recv_line according to how long we've already waited to avoid a 60 second wait dropping to 1 second due to a blocked socket. 2013-07-19 19:09:23 +10:00
Con Kolivas
1b5ea442b8 Show an integer only for diff if it is one. 2013-06-21 18:02:38 +10:00
Con Kolivas
6560878e03 Suspend stratum connections when we know they've failed and don't try to recv data from them once the socket no longer exists. 2013-06-16 22:33:49 +10:00
Con Kolivas
13a4aaa61a Failure to read and write on pseudo semaphores on apple happens routinely on shut down so should not be a quit error, just a warning. 2013-06-13 14:31:37 +10:00
Con Kolivas
12a2cb0d3c Demote failed hex2bin result to LOG_INFO and check return result in driver-bflsc to avoid doing find_work_by_midstate. 2013-06-09 22:37:49 +10:00
ckolivas
9b2e517f30 Use cgsem structures instead of the flaky pings in the work queue to start mining threads and remove the unused thr_info_freeze function. 2013-06-09 12:20:04 +10:00
ckolivas
104b14ec7f Failed reads and writes on cgsem_post and cgsem_wait should be extremely rare. 2013-06-06 13:22:12 +10:00
ckolivas
b59c33800b Implement cgminer specific cgsem semaphores to imitate unnamed semaphore behaviour on osx which does not support them. 2013-06-06 13:08:00 +10:00
Con Kolivas
d52ab244ee Provide an nusleep equivalent function to nmsleep. 2013-05-28 23:00:14 +10:00
Con Kolivas
64b08f383b All stratum calls to recv_line are serialised from the one place so there is no need to use locking around recv(). 2013-05-19 10:23:59 +10:00
Con Kolivas
f227515e38 Set pool->probed to true after an attempt to resolve the url via stratum code. 2013-05-18 13:09:01 +10:00
Con Kolivas
3336880e3b Show pool difficulty more verbosely if it changes via stratum. 2013-05-13 22:42:39 +10:00
mhren
c5bfc45233 Update util.c
Apple OS/X does not define MSG_NOSIGNAL.  Use SO_NOSIGPIPE instead
2013-05-11 23:32:57 -05:00
Con Kolivas
3972fe223b Show a different warning and loglevel for failure to resolve a URL on first or subsequent testing of stratum pool URLs. 2013-05-11 15:03:40 +10:00
Con Kolivas
2645797fca Set all stratum sockets to nonblocking to avoid trying to use MSG_DONTWAIT on windows. 2013-05-09 22:04:33 +10:00
Con Kolivas
d89936a96c Fix warnings on win32 build. 2013-05-09 21:10:53 +10:00
ckolivas
832012f61d Only use MSG_NOSIGNAL for !win32 since it doesn't exist on windows. 2013-05-09 13:42:53 +10:00
ckolivas
6acfdbd661 Use MSG_NOSIGNAL on stratum send() 2013-05-09 13:36:34 +10:00
ckolivas
a7cbbc9fc3 Set TCP_NODELAY for !linux for raw sockets. 2013-05-09 12:08:42 +10:00
ckolivas
0676a1a885 Use TCP_NODELAY with raw sockets if !opt_delaynet 2013-05-09 12:00:28 +10:00
Con Kolivas
68196588c9 Make raw sockets compile on windows 2013-05-09 11:39:09 +10:00
Con Kolivas
43bcccf868 Recheck select succeeds on EWOULDBLOCK for stratum. 2013-05-09 10:41:27 +10:00
Con Kolivas
6e969e93e2 Recv() should all be non-blocking for raw sockets in stratum. 2013-05-08 22:52:18 +10:00
Con Kolivas
cf80fe4a63 Change verbosity and error for getaddrinfo warnings in setup stratum socket. 2013-05-08 22:41:28 +10:00
Con Kolivas
1a43cb0b17 Free servinfo after p is checked in setup stratum socket. 2013-05-08 22:11:01 +10:00
Con Kolivas
31aa4f6ceb Use raw sockets without curl for stratum communications. 2013-05-08 21:59:58 +10:00
Con Kolivas
657e64477b Sacrifice curl handle memory on stratum disconnects on all versions of libcurl to avoid curl corruption. 2013-05-08 06:28:07 +10:00
Con Kolivas
891f88b601 Don't use TCP_NODELAY if opt_delaynet is enabled with stratum. 2013-05-06 16:54:55 +10:00
Kano
2ce2f8d8eb util correct applog typing 2013-05-02 23:36:04 +10:00
Kano
863c9e27df util.c str_text make a fully text readable version of str 2013-04-26 14:49:10 +10:00
Con Kolivas
d835ef75d1 Receive failures in recv_line should unconditionally fail. 2013-04-24 23:16:21 +10:00
Con Kolivas
06f7f52553 Revert "Add more debugging to recv_line parse failure."
This reverts commit b615502b2b.

Unnecessary.
2013-04-24 23:14:41 +10:00
Con Kolivas
af60a19ddd Use sock_blocks function for stratum send and receive. 2013-04-24 23:07:42 +10:00
Con Kolivas
181cb1635f There should be no error response code with return value 0 in recv_line. 2013-04-24 21:26:44 +10:00
Con Kolivas
b615502b2b Add more debugging to recv_line parse failure. 2013-04-24 21:14:20 +10:00
Con Kolivas
e95695dbc7 Check for errors on stratum recv for any recv return value less than 1 and only parse the response if it's positive. 2013-04-24 20:44:41 +10:00
James Z.M. Gao
e00a1b0e52 compile on win32 2013-04-22 11:19:15 +08:00
Con Kolivas
d2abaa8317 Provide wrappers for commonly used timer routines with API stats. 2013-04-22 10:49:10 +10:00
Con Kolivas
3cc42231f1 Fulltest is true if value is <= target. 2013-04-22 09:53:34 +10:00
Con Kolivas
3c61a51ea5 Use system host to endian functions for clarity in fulltest. 2013-04-22 09:48:41 +10:00
Con Kolivas
3d7f824363 Create a cgminer specific gettimeofday wrapper that is always called with tz set to NULL and increases the resolution on windows. 2013-04-21 19:02:44 +10:00
Con Kolivas
3b5ef34371 Add high resolution to nmsleep wrapper on windows. 2013-04-21 18:01:49 +10:00
Con Kolivas
36bb133e61 Cleanup when stratum curl fails to initialise. 2013-04-15 12:34:34 +10:00
Con Kolivas
81549c5bff Avoid applog in recalloc_sock. 2013-04-15 12:16:05 +10:00
Con Kolivas
69c203d88a Avoid applog under stratum_lock in recv_line. 2013-04-15 12:07:52 +10:00
Con Kolivas
e4effc372c Avoid applog under stratum_lock in __stratum_send. 2013-04-15 12:01:24 +10:00
Con Kolivas
d248e7aafa Put spacing around locking in util.c for clarity. 2013-04-15 11:50:59 +10:00
Con Kolivas
c1ec55a6a3 Avoid curl_easy_cleanup on old curl versions in setup_stratum_curl as well. 2013-04-09 07:08:09 +10:00
Con Kolivas
1e14748c68 Small timeouts on select() instead of instant timeout increase reliability of socket reads and writes. 2013-04-06 16:38:11 +11:00
Con Kolivas
c6ca12f084 Differentiate socket closed from socket error in recv_line. 2013-04-06 11:22:30 +11:00
Con Kolivas
b6e3d5b4fa Make pool adding while running asynchronous, using the pool test thread functionality. 2013-03-14 22:34:53 +11:00
Con Kolivas
1a74bc5631 Only curl easy cleanup a stratum curl if it exists. 2013-03-14 22:08:19 +11:00
Con Kolivas
195ea63589 Sacrifice the ram of curl handles in stratum disconnects when we have built with old libcurl to avoid crashes. 2013-03-14 22:05:42 +11:00
Con Kolivas
26ddd1fd20 Move the stratum and GBT data to be protected under a new cg_lock data_lock. 2013-03-12 22:31:45 +11:00
Con Kolivas
66c567ab2e Use curl_easy_cleanup to close any open stratum sockets. 2013-03-09 12:13:12 +11:00
Con Kolivas
7e3ca57049 Set sockd to false should curl setup fail on stratum. 2013-03-09 10:41:36 +11:00
Con Kolivas
56068d6839 Close any open sockets when reusing a curl handle and reopen the socket whenever we're retrying stratum. 2013-03-09 10:30:58 +11:00
Con Kolivas
09c02b1c7b Shorten the time before keepalive probes are sent out and how frequently they're sent with stratum curls. 2013-03-07 22:02:51 +11:00
Con Kolivas
501f4cd6ec Clear the socket of anything in the receive buffer if we're going to retry connecting. 2013-03-07 19:59:30 +11:00
Con Kolivas
c9b4f5c757 Revert "Cope with out of order messages coming in upon attempting to auth_stratum."
This reverts commit 237f67c617.
2013-03-07 15:34:44 +11:00
Con Kolivas
ed903ddf31 Clear just the socket buffer when we don't care what is left in a stratum socket. 2013-03-07 15:13:32 +11:00
Con Kolivas
fbb25c4ba5 Clear the stratum socket whenever we are closing it since the buffer is going to be reused. 2013-03-07 15:10:38 +11:00
Con Kolivas
0810212c9a Reset stratum_notify flag on suspend_stratum as well. 2013-03-07 14:20:33 +11:00
Con Kolivas
07ae6172cc Close any sockets opened if we fail to initiate stratum but have opened the socket. 2013-03-07 14:15:28 +11:00
Con Kolivas
6875dc46b6 Close any existing stratum socket if we are attempting to restart stratum so the pool knows the connection has gone. 2013-03-07 13:50:25 +11:00
Con Kolivas
237f67c617 Cope with out of order messages coming in upon attempting to auth_stratum. 2013-03-07 11:36:04 +11:00
Con Kolivas
e3151799b6 Implement client.show_message support for stratum. 2013-03-07 08:42:14 +11:00
Con Kolivas
0be6e9e76c Make sure to retry only once with noresume support for stratum. 2013-03-06 21:01:46 +11:00
Con Kolivas
5abcf06bbe Merge branch 'master' into usb-dev 2013-02-25 10:44:54 +11:00
Con Kolivas
3c949e5f6c Try to extract the sessionid associated with mining.notify on 3rd level array and submit it along with the userid to support mining resume, failing gracefully and restarting if the pool rejects it. 2013-02-25 10:43:48 +11:00
Con Kolivas
5a3b374962 Update copyright dates. 2013-02-25 08:59:11 +11:00
Con Kolivas
6bf79626b8 Merge branch 'master' into usb-dev 2013-02-23 13:59:37 +11:00
Con Kolivas
3dcdb94921 Cope with misread sessionid on stratum for now. 2013-02-23 13:07:47 +11:00
ckolivas
6a0882f05b Use the sessionid as passed on stratum connect to attempt to resume a connection once and then clear it if it fails, to use a new connection. 2013-02-22 16:55:39 +11:00
ckolivas
68d691093c Move to storing the nonce1 in the work struct instead of the sessionid for the now defunct first draft mining.resume protocol. 2013-02-22 12:55:01 +11:00
ckolivas
22a50a5a0f Merge branch 'usb-dev' of github.com:ckolivas/cgminer into usb-dev 2013-02-17 00:10:36 +11:00
Con Kolivas
a7859bb416 Merge pull request #386 from luke-jr/bugfix_20130215a
Bugfix: Missing pool_no parameter to applog for no-stratum-sessionid debug message
2013-02-16 03:52:06 -08:00
Luke Dashjr
7473c3dc94 Bugfix: Missing pool_no parameter to applog for no-stratum-sessionid debug message 2013-02-16 05:06:38 +00:00
Con Kolivas
ab0cc58cb4 Merge branch 'master' into usb-dev 2013-02-15 23:15:11 +11:00
Con Kolivas
be4705a003 Provide support for mining.resume with stratum, currently re-authorising after successful resumption pending finalising of the protocol process. 2013-02-15 23:05:29 +11:00
Con Kolivas
4cde791e9f Provide basic framework for restarting stratum depending on whether resume support exists or not. 2013-02-15 21:31:44 +11:00
Con Kolivas
c29df9760f Abstract out the setting up of the stratum curl socket. 2013-02-15 21:03:39 +11:00
Con Kolivas
c851f39598 Store session id for stratum if the pool supports it for future mining.resume support. 2013-02-15 14:46:30 +11:00
Kano
c432c655f7 debug_cb buffer type warning 2013-02-13 14:50:55 +11:00
Con Kolivas
3c91b292a2 Merge branch 'master' into usb-dev 2013-02-07 18:02:38 +11:00
Con Kolivas
903c666326 Fix logic fail on partial writes with stratum send that was leading to corrupt message submissions. 2013-02-07 16:38:11 +11:00
Con Kolivas
0244998ef8 Merge branch 'master' into usb-dev 2013-02-04 11:23:20 +11:00
Con Kolivas
d644fdf1f4 Cache the coinbase length to speed up stratum work generation. 2013-02-04 11:19:12 +11:00
Con Kolivas
0870ab7532 Cache the header length when generating stratum work to avoid calculating it on every work generation, and to only need one alloc+sprintf, speeding up work generation. 2013-02-04 11:06:05 +11:00
Con Kolivas
51d11a28f9 Provide a wrapper for aligning lengths of size_t to 4 byte boundaries. 2013-02-04 10:19:12 +11:00
Kano
c1eae36f7b API stats - include pool network bytes + in miner.php 2013-02-02 20:14:33 +11:00
Con Kolivas
e1387dc85c Change the pool stratum socket buffer to be dynamically allocated to accomodate any size coinbase and keep receiving data in recv line for up to 60s if no end of line has been received. 2012-12-29 11:29:59 +11:00
Con Kolivas
6e2e7d36de Differentiate socket full from sock full. 2012-12-29 10:46:55 +11:00
Con Kolivas
7f46f6e91f Allow stratum to startup without notify but check it is valid before creating stratum work. 2012-12-29 10:42:45 +11:00
Con Kolivas
e1d7ecdd35 Do not try to generate stratum work unless the notify command has succeeded. 2012-12-29 09:45:40 +11:00
Con Kolivas
944af31b99 Parse anything in the stratum socket if it's full without waiting. Empty the socket even if a connection is not needed in case there are share returns. 2012-12-26 09:31:41 +11:00
Con Kolivas
cada0d3195 Check for EWOULDBLOCK when supported in send and recv as well. 2012-12-14 21:36:42 +11:00
Con Kolivas
2274af6a05 Use the raw send() command instead of curl_easy_send since curl raw socket usage introduces random bugs on windows. 2012-12-14 21:29:33 +11:00
Con Kolivas
f66d59df03 Use raw recv() command in place of curl_easy_recv since the curl implementation introduces random bugs on windows builds when the recv fails. 2012-12-14 21:20:52 +11:00
Kano
138465bf0c Pool store data transfer stats 2012-12-13 00:56:10 +11:00
Con Kolivas
ac3020f45b Include prctl header for thread renaming to work. 2012-12-10 22:02:31 +11:00
Con Kolivas
15e5e36bcd Return value of keep_sockalive is no longer used. 2012-12-09 14:13:24 +11:00
Con Kolivas
8fcc67f308 Remove dependency on mstcpip.h for windows build by making curl version >= 7.25.0 mandatory on windows builds, and use curl functions for keepalive whenever possible instead. 2012-12-09 13:39:37 +11:00
Con Kolivas
68f1b2c4b5 Set successful connect to true on auth stratum to allow summary on exit from single stratum pool. 2012-12-08 22:14:47 +11:00
Con Kolivas
be013e9699 Set pool probed to true on successful authorisation with stratum to avoid it being pinged later with pool_getswork. 2012-12-07 09:37:37 +11:00
Con Kolivas
fc5d3a0eaf Suspend stratum connections to backup pools when there is no requirement to potentially grab work from them. 2012-12-03 09:52:46 +11:00
Denis Ahrens
271b05ab04 setting the name of the threads for linux,freebsd,openbsd and osx
code is borrowed from bitcoins util.c, so it is already tested
2012-12-02 11:39:20 +01:00
Con Kolivas
fc66a41e85 Style police. 2012-12-02 20:49:40 +11:00
Con Kolivas
f94cff77e6 Microoptimise and remove redundant copy of strdup function in calloc_strcat. 2012-12-02 18:06:55 +11:00
Con Kolivas
0ae02c6ec4 Since we will be using calloc_str to put a string into it, convert the function to calloc_strcat which does it automatically. 2012-12-01 08:26:31 +11:00
Con Kolivas
ee8609d9a9 Provide helper functions calloc_str and realloc_strcat to create and extend arbitrary length arrays based on string length. 2012-11-29 12:48:17 +11:00
nelisky
6db7e2e5cf fixes target calc for mips openwrt 2012-11-24 13:12:19 -08:00
Con Kolivas
0b088d8d81 Provide rudimentary support for literal ipv6 addresses when parsing stratum URLs. 2012-11-18 18:08:14 +11:00
Con Kolivas
f14bf5b16c Merge pull request #326 from pshep/error_counters
Error counters
2012-11-17 22:06:49 -08:00
Con Kolivas
b3864d1a94 Support for fractional diffs and the classic just-below-1 share all FFs diff target. 2012-11-15 09:18:58 +11:00
Paul Sheppard
dad6c70420 Merge branch 'master' into error_counters 2012-11-06 09:46:05 -08:00
Con Kolivas
cc7c274543 Manage appropriate response codes for share submission with GBT. 2012-11-05 16:28:52 +11:00
Paul Sheppard
84173c6cc7 missing a break. 2012-11-04 20:38:11 -08:00
Paul Sheppard
9f74e650b3 Tidy up device error counts 2012-11-04 20:17:43 -08:00