-
Notifications
You must be signed in to change notification settings - Fork 6
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
Switch to using blake3 hashes and skipping empty blocks #29
Conversation
315b90d
to
57482b7
Compare
/cc @rayfordj If you could review? |
f.log.V(5).Info("Comparing hash of hashes", "hash", base64.StdEncoding.EncodeToString(f.hashHash)) | ||
if n, err := rw.Write(f.hashHash); err != nil { | ||
return false, err | ||
} else { |
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: no need for an else
statement here
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.
Actually I do need the else here, because I am referencingn
which only exists in the scope of the if statement.
if n, err := io.ReadFull(rw, hashHash); err != nil { | ||
return false, err | ||
} else { | ||
f.log.V(5).Info("Read hash of hashes", "bytes", n, "hash", base64.StdEncoding.EncodeToString(hashHash)) |
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.
same
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.
Same reason the else exists.
pkg/blockrsync/hasher_test.go
Outdated
@@ -64,7 +64,7 @@ var _ = Describe("hasher tests", func() { | |||
Expect(err).ToNot(HaveOccurred()) | |||
hashes := hasher.GetHashes() | |||
// 16 for the blocksize and length, 72 for each hash |
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.
fix comment
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.
Done
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.
Just some nits, but aside from that VISIACK
Blake3 hashes are significantly faster than blake2 hashes used previously. Also added faster empty block detection so those don't need to get hashed at all. Signed-off-by: Alexander Wels <[email protected]>
Fixed the comment, the elses are still needed because of a variable only visible in the scope of the if statement. |
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.
Overall looks good.
pkg/blockrsync/hasher.go
Outdated
@@ -30,6 +36,7 @@ type Hasher interface { | |||
SerializeHashes(io.Writer) error | |||
DeserializeHashes(io.Reader) (int64, map[int64][]byte, error) | |||
BlockSize() int64 | |||
CompareHashHash(io.ReadWriter) (bool, error) |
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.
find this name confusing, maybe s/HashHash/HashOfHash/
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.
Done
Renamed hashhash to hashofhash Signed-off-by: Alexander Wels <[email protected]>
Blake3 hashes are significantly faster than blake2 hashes used previously. Also added faster empty block detection so those don't need to get hashed at all.