-
Notifications
You must be signed in to change notification settings - Fork 13
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
Optimize PoW #419
Optimize PoW #419
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #419 +/- ##
=======================================
Coverage 75.1% 75.1%
=======================================
Files 23 24 +1
Lines 1917 1926 +9
=======================================
+ Hits 1440 1448 +8
Misses 359 359
- Partials 118 119 +1
|
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.
lgtm
} | ||
|
||
func NewPowHasher(inputs ...[]byte) *powHasher { | ||
h := &powHasher{h: ripemd.New256(), input: []byte{}} |
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.
NIT: h.input
does not need to be initialized to append bytes to it
h := &powHasher{h: ripemd.New256(), input: []byte{}} | |
h := &powHasher{h: ripemd.New256()} |
|
||
nonce, err := shared.FindSubmitPowNonce(context.Background(), challenge, poetChallenge, nodeID, difficulty) | ||
require.NoError(t, err) | ||
require.EqualValues(t, 143, nonce) |
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.
NIT: EqualValues
ignores typing; I think this assertion should fail if someone accidentally changes the type of nonce
:
require.EqualValues(t, 143, nonce) | |
require.Equal(t, uint64(143), nonce) |
Part of #416
Optimizes the proof of work:
Single hash benchmark:
Finding PoW benchmark: