Author

Topic: Exact definition of POW (Read 909 times)

legendary
Activity: 1190
Merit: 1004
May 11, 2013, 08:54:34 AM
#10
Shouldn't it be the same?  I guess it doesn't matter much, since a tie isn't likely to last long.

The result is the same but the code is different.

The next target in the satoshi client is calculated here: https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L1110

The "bits" field contains the claimed target for the block. The target is different than the block work, but the block work is derived from the target.
legendary
Activity: 1232
Merit: 1094
May 11, 2013, 08:12:43 AM
#9
If you are looking for the math that updates the expected next target once a 2016 block window has been completed, let me know.

I have read it before.  My memory is that it calculates the target, not the difficulty.  As you say the link gives the official definition.

(1 << 256) / (target + 1)
kjj
legendary
Activity: 1302
Merit: 1026
May 11, 2013, 06:51:46 AM
#8
Ahh, ok.  In that case, you need to look at the header.  The exact integer amount of work that a block is "worth" is encoded in the bits field.  The wiki page describes the format, and someone already posted a link into the actual source where the calculation is done.

If you are looking for the math that updates the expected next target once a 2016 block window has been completed, let me know.  I think it is in main.cpp, and I can find it, it is just annoying to do from this computer.  It basically calculates what the difficulty in the previous window should have been to get an average of 10 minutes per block.

Edit:  Oh, blocks that have the wrong difficulty in the header are rejected as invalid, so there won't be any subtle disagreements,
legendary
Activity: 1232
Merit: 1094
May 11, 2013, 02:16:35 AM
#7
Same?  Tie?

Work is based on the difficulty, not the hash.

The point is that if you have a different formula for working out the POW per block, you could have 2 chains, where there is disagreement on which one has more POW.  However, as long as they are nearly the same, 1 - 2 blocks should move one ahead of the other.
kjj
legendary
Activity: 1302
Merit: 1026
May 10, 2013, 09:59:14 PM
#6
The proof-of-work  is a method/system for demonstrating that work has been done. I guess you mean the block work, ie. the number used as the extent to which work has been done. You can see how it is calculated in the satoshi client here: https://github.com/bitcoin/bitcoin/blob/33edd0a477f4448be9c6c4949fbff4e53f16cac6/src/main.h#L1725

No idea why it is in the header file.

In cbitcoin the calculation is a bit more complicated: https://github.com/MatthewLM/cbitcoin/blob/master/src/CBValidationFunctions.c#L28


Shouldn't it be the same?  I guess it doesn't matter much, since a tie isn't likely to last long.

Same?  Tie?

Work is based on the difficulty, not the hash.
legendary
Activity: 1232
Merit: 1094
May 10, 2013, 08:32:51 PM
#5
The proof-of-work  is a method/system for demonstrating that work has been done. I guess you mean the block work, ie. the number used as the extent to which work has been done. You can see how it is calculated in the satoshi client here: https://github.com/bitcoin/bitcoin/blob/33edd0a477f4448be9c6c4949fbff4e53f16cac6/src/main.h#L1725

No idea why it is in the header file.

In cbitcoin the calculation is a bit more complicated: https://github.com/MatthewLM/cbitcoin/blob/master/src/CBValidationFunctions.c#L28


Shouldn't it be the same?  I guess it doesn't matter much, since a tie isn't likely to last long.
legendary
Activity: 2058
Merit: 1452
May 10, 2013, 07:32:32 PM
#4
The POW for a block is equal to 1/target.  Is there an exact way to calculate it?  Presumably, it is an integer division and so approximate.
floating point is approximate (rounding rules dependent on implementation and precision), integer division isn't.
member
Activity: 63
Merit: 10
Vires in Numeris
May 10, 2013, 07:25:55 PM
#3
No... The POW of a block is the nonce which makes the hash below the target. It's not 1/target. Maybe you mean that one in every 2^256/target nonces will be below the target?
legendary
Activity: 1190
Merit: 1004
May 10, 2013, 07:21:58 PM
#2
The proof-of-work  is a method/system for demonstrating that work has been done. I guess you mean the block work, ie. the number used as the extent to which work has been done. You can see how it is calculated in the satoshi client here: https://github.com/bitcoin/bitcoin/blob/33edd0a477f4448be9c6c4949fbff4e53f16cac6/src/main.h#L1725

No idea why it is in the header file.

In cbitcoin the calculation is a bit more complicated: https://github.com/MatthewLM/cbitcoin/blob/master/src/CBValidationFunctions.c#L28
legendary
Activity: 1232
Merit: 1094
May 10, 2013, 07:01:42 PM
#1
The POW for a block is equal to 1/target.  Is there an exact way to calculate it?  Presumably, it is an integer division and so approximate.
Jump to: