Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getblock returns slightly different difficulty than bitcoin core #414

Closed
arnuschky opened this issue May 4, 2015 · 4 comments · Fixed by #415
Closed

getblock returns slightly different difficulty than bitcoin core #414

arnuschky opened this issue May 4, 2015 · 4 comments · Fixed by #415

Comments

@arnuschky
Copy link

Not sure if relevant, again just reporting differences.

bitcoin core:

{u'bits': u'1c2f7e80',
 u'confirmations': 38872,
 u'difficulty': Decimal('5.39005634'),
 u'hash': u'000000002625e7a7960aaeceaefdd7f187e9da93abaf097c11dde293dfbf08a0',
 u'height': 353665,
 u'merkleroot': u'818bd73d11d4cece7a8d73cc1173aa61a993f542f40c708db4a43ae10a84f736',
 u'nextblockhash': u'0000000025e1d96963213ebd2023861c3c157707e0cb76a76cb265cac8cca20e',
 u'nonce': 2880533359,
 u'previousblockhash': u'0000000021ca73c8b25d7d4dd887f8df891c6730f96bb063aa2a43acf515d127',
 u'size': 208,
 u'time': 1429984191,
 u'tx': [u'818bd73d11d4cece7a8d73cc1173aa61a993f542f40c708db4a43ae10a84f736'],
 u'version': 3}

btcd:

{u'bits': u'1c2f7e80',
 u'confirmations': 38872,
 u'difficulty': Decimal('5.39'),
 u'hash': u'000000002625e7a7960aaeceaefdd7f187e9da93abaf097c11dde293dfbf08a0',
 u'height': 353665,
 u'merkleroot': u'818bd73d11d4cece7a8d73cc1173aa61a993f542f40c708db4a43ae10a84f736',
 u'nextblockhash': u'0000000025e1d96963213ebd2023861c3c157707e0cb76a76cb265cac8cca20e',
 u'nonce': 2880533359,
 u'previousblockhash': u'0000000021ca73c8b25d7d4dd887f8df891c6730f96bb063aa2a43acf515d127',
 u'size': 208,
 u'time': 1429984191,
 u'tx': [u'818bd73d11d4cece7a8d73cc1173aa61a993f542f40c708db4a43ae10a84f736'],
 u'version': 3}
@davecgh
Copy link
Member

davecgh commented May 4, 2015

That's just a human readable ratio of max pow limit over the bits field. We've limited it to a precision of 2 whereas they limit it to 8. The bits field is the one that actually matters.

You'll notice that the various block explorers show a different precision after the decimal as well:
https://tbtc.blockr.io/block/info/353665 (3 digits)
https://chain.so/block/BTCTEST/353665 (2 digits)
https://blockexplorer.com/testnet/b/353665 (6 digits)

I'll leave this open for a bit to give others a chance to comment, but this can be closed in my opinion.

@arnuschky
Copy link
Author

Two digits sound reasonable to me, but again, we are not using this field.

Note that the two explorers you've mentioned only show a limited precision on their website. Both APIs report the exact same value as bitcoin core. (which is most likely running in the background, I guess)

@davecgh
Copy link
Member

davecgh commented May 4, 2015

Fair enough. It's a simple change and doesn't hurt anything to provide the extra precision. I'll submit a PR in a few for it.

davecgh added a commit to davecgh/btcd that referenced this issue May 4, 2015
This commit increases the precision of the difficulty field of the
getblock RPC to 8 to match Bitcoin Core.

Closes btcsuite#414.
@arnuschky
Copy link
Author

Confirmed working here, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants