mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-31 17:04:23 +00:00
Added support for quarkcoin difficulty calculation.
This commit is contained in:
parent
a17ec112f6
commit
60a0e00243
@ -48,7 +48,7 @@ extern bool opt_loginput;
|
||||
extern char *opt_kernel_path;
|
||||
extern int gpur_thr_id;
|
||||
extern bool opt_noadl;
|
||||
extern bool is_scrypt;
|
||||
extern enum diff_calc_mode dm_mode;
|
||||
|
||||
extern void *miner_thread(void *userdata);
|
||||
extern int dev_from_id(int thr_id);
|
||||
@ -228,8 +228,12 @@ char *set_kernel(char *arg)
|
||||
if (kern == KL_NONE)
|
||||
return "Invalid parameter to set_kernel";
|
||||
gpus[device++].kernel = kern;
|
||||
// if (kern >= KL_DARKCOIN)
|
||||
// is_scrypt = false;
|
||||
if (kern >= KL_DARKCOIN)
|
||||
dm_mode = DM_BITCOIN;
|
||||
else if(kern >= KL_QUARKCOIN)
|
||||
dm_mode = DM_QUARKCOIN;
|
||||
else
|
||||
dm_mode = DM_LITECOIN;
|
||||
|
||||
while ((nextptr = strtok(NULL, ",")) != NULL) {
|
||||
kern = select_kernel(nextptr);
|
||||
|
8
miner.h
8
miner.h
@ -381,8 +381,8 @@ enum cl_kernels {
|
||||
KL_CKOLIVAS,
|
||||
KL_PSW,
|
||||
KL_ZUIKKIS,
|
||||
KL_DARKCOIN,
|
||||
KL_QUARKCOIN,
|
||||
KL_DARKCOIN,
|
||||
};
|
||||
|
||||
enum dev_reason {
|
||||
@ -1500,4 +1500,10 @@ extern struct api_data *api_add_diff(struct api_data *root, char *name, double *
|
||||
extern struct api_data *api_add_percent(struct api_data *root, char *name, double *data, bool copy_data);
|
||||
extern struct api_data *api_add_avg(struct api_data *root, char *name, float *data, bool copy_data);
|
||||
|
||||
enum diff_calc_mode {
|
||||
DM_BITCOIN,
|
||||
DM_QUARKCOIN,
|
||||
DM_LITECOIN,
|
||||
};
|
||||
|
||||
#endif /* __MINER_H__ */
|
||||
|
21
sgminer.c
21
sgminer.c
@ -299,7 +299,10 @@ struct schedtime {
|
||||
struct schedtime schedstart;
|
||||
struct schedtime schedstop;
|
||||
bool sched_paused;
|
||||
bool is_scrypt = true;
|
||||
|
||||
#define DM_SELECT(x, y, z) (dm_mode == DM_BITCOIN ? x : (dm_mode == DM_QUARKCOIN ? y : z))
|
||||
|
||||
enum diff_calc_mode dm_mode = DM_LITECOIN;
|
||||
|
||||
static bool time_before(struct tm *tm1, struct tm *tm2)
|
||||
{
|
||||
@ -2959,7 +2962,7 @@ static void calc_diff(struct work *work, double known)
|
||||
else {
|
||||
double d64, dcut64;
|
||||
|
||||
d64 = (is_scrypt ? (double)65536 * truediffone : truediffone);
|
||||
d64 = (double) DM_SELECT(1, 256, 65536) * truediffone;
|
||||
|
||||
dcut64 = le256todouble(work->target);
|
||||
if (unlikely(!dcut64))
|
||||
@ -3576,7 +3579,7 @@ static double share_diff(const struct work *work)
|
||||
double d64, s64;
|
||||
double ret;
|
||||
|
||||
d64 = (is_scrypt ? (double)65536 * truediffone : truediffone);
|
||||
d64 = (double) DM_SELECT(1, 256, 65536) * truediffone;
|
||||
s64 = le256todouble(work->hash);
|
||||
if (unlikely(!s64))
|
||||
s64 = 0;
|
||||
@ -3899,7 +3902,7 @@ static void set_blockdiff(const struct work *work)
|
||||
uint8_t pow = work->data[72];
|
||||
int powdiff = (8 * (0x1d - 3)) - (8 * (pow - 3));
|
||||
uint32_t diff32 = be32toh(*((uint32_t *)(work->data + 72))) & 0x00FFFFFF;
|
||||
double numerator = (is_scrypt ? 0xFFFFFFFFULL : 0xFFFFULL) << powdiff;
|
||||
double numerator = DM_SELECT(0xFFFFULL, 0xFFFFFFULL, 0xFFFFFFFFULL) << powdiff;
|
||||
double ddiff = numerator / (double)diff32;
|
||||
|
||||
if (unlikely(current_diff != ddiff)) {
|
||||
@ -5818,7 +5821,7 @@ void set_target(unsigned char *dest_target, double diff)
|
||||
}
|
||||
|
||||
// FIXME: is target set right?
|
||||
d64 = (is_scrypt ? (double)65536 * truediffone : truediffone);
|
||||
d64 = (double) DM_SELECT(1, 256, 65536) * truediffone;
|
||||
d64 /= diff;
|
||||
|
||||
dcut64 = d64 / bits192;
|
||||
@ -6064,7 +6067,7 @@ bool test_nonce_diff(struct work *work, uint32_t nonce, double diff)
|
||||
uint64_t *hash64 = (uint64_t *)(work->hash + 24), diff64;
|
||||
|
||||
rebuild_nonce(work, nonce);
|
||||
diff64 = (is_scrypt ? 0x0000ffff00000000ULL : 0x00000000ffff0000ULL);
|
||||
diff64 = DM_SELECT(0x00000000ffff0000ULL, 0x000000ffff000000ULL, 0x0000ffff00000000ULL);
|
||||
diff64 /= diff;
|
||||
|
||||
return (le64toh(*hash64) <= diff64);
|
||||
@ -6073,13 +6076,11 @@ bool test_nonce_diff(struct work *work, uint32_t nonce, double diff)
|
||||
static void update_work_stats(struct thr_info *thr, struct work *work)
|
||||
{
|
||||
double test_diff = current_diff;
|
||||
if (is_scrypt)
|
||||
test_diff *= 65536;
|
||||
test_diff *= DM_SELECT(1, 256, 65536);
|
||||
|
||||
work->share_diff = share_diff(work);
|
||||
|
||||
if (is_scrypt)
|
||||
test_diff *= 65536;
|
||||
test_diff *= DM_SELECT(1, 256, 65536);
|
||||
|
||||
if (unlikely(work->share_diff >= test_diff)) {
|
||||
work->block = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user