This is a C/C++ programming question related to CPU mining. In the source code for CPU miners wolf-xmr-miner, cpuminer-multi et al there is a function called scanhash_cryptonight
that has this the following prototype:
int scanhash_cryptonight(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
uint32_t max_nonce, uint64_t *hashes_done);
The parameters pdata
and ptarget
are pointers to members of a struct that looks like this:
struct work {
uint32_t data[32];
uint32_t target[8];
/* ... */
};
Now when scanhash_cryptonight
is called there is this nonceptr
variable that is initialized like this (link to scanhash function):
uint32_t *nonceptr = (uint32_t*) (((char*)pdata) + 39);
My question is: what is the value of nonceptr
used for and what is the casting in the expresssion doing?
block_hashing_blob
? It's incremented by miners and used in the cryptonight PoW hash to find a block that is below a certain difficulty target. – moo Dec 20 '17 at 01:33blockhashing_blob
. However, there are some variable size integers before the nonce in the block header (version numbers, timestamp), so in the future if at least one of them gets big enough for its serialization to require more bytes to be stored, the offset of the nonce will increase. – glv Dec 20 '17 at 09:10