Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Proof of work
A proof-of-work is a solution for difficult (costly) mathematical task. This solution must be trivial to check whether data satisfies claimed requirements.
Novacoin uses the hashcash method to provide proofs of the work. The difficulty of this work is adjusted so as to limit the rate at which new blocks can be generated by the network to required target spacing rate (from 10 to 30 minutes). Due to the very low probability of successful proof generation, this makes it unpredictable which worker computer in the network will be able to generate the next solution.
How long will it take me to generate a proof-of-work?
No-one can say exactly. But there is an estimation of how long it might take.
Imagine that you have a hardware with 1 MH/s hashing speed. Let's estimate how much time the generation of proof-of-work will take from you in average, with a current Novacoin proof-of-work difficulty.
Difficulty 1.0 is represented by
value of target. So, to get a successful proof of work we need to perform
0xFFFFFFFFFFFFFFFF / 0x00000000FFFFFFFF or ~
At difficulty 360 we need ~
360 * 4294967297 =
1546188226920 attempts. If you have 1 MH/s or 1000000 hashes per second then you will be able to scan such amount of hashes within
1546188226920 / 1000000 =
1546188 seconds or
1546188 / 86400 =
Probability of successful block generation during one day could be calculated from available hashrate using formula:
P = nHashesPerSecond * 86400 / (4294967297 * difficulty)
How does it work?
Each block header represented by structure of 6 fields, a some of this fields could be varied pretty freely.
|nVersion||unsigned int||4||Shouldn't be modified manually.|
|hashPrevBlock||unsigned char||32||Shouldn't be modified manually.|
|hashMerkleRoot||unsigned char||32||It's a merkle tree hash. Could be modified through modification, addition or removal of transactions.|
|nTime||unsigned int||4||Can be updated manually to any value from [max tx timestamp, time() + 3600] interval.|
|nBits||unsigned int||4||Shouldn't be updated manually|
|nNonce||unsigned int||4||Attempts counter for proof-of-work. You need to update this field for every new hashing attempt.|
The hashing result of a valid proof-of-work value must be lower than current target. Miner tries to find this suitable solution by scanning all possible nNonce values (from 0 to UINT_MAX). In case of overflow the new coinbase transaction will be created. This allows miner to replace a value of new merkle tree hash with a new one and start nNonce scanning from zero again. Adjustment of timestamp is also possible.
What about rewards?
Block reward can be calculated using formula
nBlockReward = 100 / (diffuculty / 0,000244) ^ (1/6)
This means, that reward starts from 100 coins and cut in a half every 64x multiply of difficulty.