-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Add Block proof-of-work validation function #509
Conversation
}) | ||
|
||
it('returns ' + f.valid + ' for ' + f.id, function () { | ||
assert.strictEqual(block.verifyPow(), f.valid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jprichardson @weilu any thoughts on verifyPow
as a name?
Removed the need for |
Mostly good to go now 👍 , just need a few more fixtures to verify that |
dc94583
to
ccfba68
Compare
target.fill(0) | ||
|
||
var exponent = ((bits & 0xff000000) >> 24) - 3 | ||
var value = bits & 0x00ffffff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its unclear if this should be bits & 0x007fffff
or 0x00ffffff
.
I'm happy with this as is for now, will wait to enforce that it verifies for the mainnet blockchain before merge.
33d7b57
to
b1cdfaa
Compare
Matched against every possible |
Add Block proof-of-work validation function
@jprichardson guessing you were OK with this API? If not, please comment within 24 hours :) |
Yep :) ACK. |
Might be a way to do this nicely without resorting to using
bigi
, but, for now, here it is.Should probably get some more test fixtures from core if possible.
Block.calculateTarget
(reference: https://en.bitcoin.it/wiki/Target)Block.prototype.verifyPow