File tree Expand file tree Collapse file tree 4 files changed +29
-19
lines changed
Expand file tree Collapse file tree 4 files changed +29
-19
lines changed Original file line number Diff line number Diff line change @@ -52,3 +52,10 @@ string format_seconds(uint64_t seconds) {
5252 ss << std::setw (2 ) << std::setfill (' 0' ) << hours << " :" << std::setw (2 ) << std::setfill (' 0' ) << minutes << " :" << std::setw (2 ) << std::setfill (' 0' ) << reminder;
5353 return ss.str ();
5454}
55+
56+ string format_hashrate (int hashrate) {
57+ double khs = (double )hashrate / 1000.0 ;
58+ char buff[20 ];
59+ sprintf (buff, " %.1fk" , khs);
60+ return string (buff);
61+ }
Original file line number Diff line number Diff line change @@ -58,5 +58,6 @@ DLLEXPORT vector<string> get_files(string folder);
5858DLLEXPORT bool is_number (const string &s);
5959DLLEXPORT string generate_uid (size_t length);
6060DLLEXPORT string format_seconds (uint64_t seconds);
61+ DLLEXPORT string format_hashrate (int hashrate);
6162
6263#endif // IXIMINER_COMMON_H
Original file line number Diff line number Diff line change 77#include " hex.h"
88
99void hex::encode (const unsigned char *input, int input_size, char *output) {
10- for (int i=0 ; i<input_size; i++) {
11- sprintf (output, " %02x" , input[i]);
12- output+=2 ;
10+ for ( int i=0 ; i<input_size; i++ ) {
11+ char b1= *input >> 4 ; // hi nybble
12+ char b2= *input & 0x0f ; // lo nybble
13+ b1+=' 0' ; if (b1>' 9' ) b1 += 7 ; // gap between '9' and 'A'
14+ b2+=' 0' ; if (b2>' 9' ) b2 += 7 ;
15+ *(output++)= b1;
16+ *(output++) = b2;
17+ input++;
1318 }
19+ *output = 0 ;
1420}
1521
1622int hex::decode (const char *input, unsigned char *output, int output_size) {
17- char buff[3 ];
18- size_t input_size = strlen (input);
19- if (output_size < input_size / 2 )
20- return -1 ;
21-
22- for (int i=0 ; i<input_size; i+=2 ) {
23- strncpy (buff, &input[i], 2 );
24- output[i/2 ] = strtoul (buff, NULL , 16 );
23+ size_t in_len = strlen (input);
24+ for ( int i=0 ; i<in_len; i+=2 ) {
25+ unsigned char b1= input[i] -' 0' ; if (b1>9 ) b1 -= 7 ;
26+ unsigned char b2= input[i+1 ] -' 0' ; if (b2>9 ) b2 -= 7 ;
27+ *(output++) = (b1<<4 ) + b2; // <<4 multiplies by 16
2528 }
26-
27- return input_size / 2 ;
29+ return in_len / 2 ;
2830}
Original file line number Diff line number Diff line change @@ -268,17 +268,17 @@ bool miner::__display_report() {
268268 hash_count += (*it)->get_hash_count ();
269269 }
270270
271- header << " |TotalHR" ;
272- log << " |" << setw (7 ) << ( int )hash_rate;
271+ header << " | TotalHR" ;
272+ log << " |" << setw (8 ) << format_hashrate (( int )hash_rate) ;
273273 for (vector<hasher *>::iterator it = hashers.begin (); it != hashers.end (); ++it) {
274274 map<int , device_info> devices = (*it)->get_device_infos ();
275275 for (map<int , device_info>::iterator d = devices.begin (); d != devices.end (); ++d) {
276- header << " |" << ((d->first < 10 ) ? " " : " " ) << (*it)->get_type () << d->first ;
277- log << " |" << setw (5 ) << ( int )(d->second .hashrate );
276+ header << " |" << ((d->first < 10 ) ? " " : " " ) << (*it)->get_type () << d->first ;
277+ log << " |" << setw (6 ) << format_hashrate (( int )(d->second .hashrate ) );
278278 }
279279 }
280- header << " |Avg | Time|Acc |Rej |Block|" ;
281- log << " |" << setw (6 ) << ( int )avg_hash_rate
280+ header << " | Avg | Time|Acc |Rej |Block|" ;
281+ log << " |" << setw (7 ) << format_hashrate (( int )avg_hash_rate)
282282 << " |" << setw (9 ) << format_seconds (total_time)
283283 << " |" << setw (6 ) << __confirmed
284284 << " |" << setw (6 ) << __rejected
You can’t perform that action at this time.
0 commit comments