Author

Topic: How to access the calculated difficulty in the code? (Read 627 times)

-ck
legendary
Activity: 4088
Merit: 1631
Ruu \o/
Check out how I do it in cgminer with the set_blockdiff function

https://github.com/ckolivas/cgminer/blob/master/cgminer.c#L4302

ddiff is the calculated diff as a double
newbie
Activity: 17
Merit: 500
I am experimenting with some new functions using the Bitcoin code.

I am in main.cpp and would like to do some arithmetic inside the code, using the value of the calculated Difficulty as one of the parameters (the same real value that shows when we ask  "getdifficulty" with the executable client).

I am sorry to say that I am not very good with C++, so I have a little of difficulty resolving the correct syntax. 

I came up with something like that to calculate the difficulty:

double dDiff = (double)0x0000ffff / (double)CBlockIndex* blockindex->nBits & 0x00ffffff;

But can't get it to compile.  Obviously my syntax is wrong... and I most likely not declaring some variables somewhere....

How should I write it?

Jump to: