-
Notifications
You must be signed in to change notification settings - Fork 57
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
murmur3 support #150
murmur3 support #150
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
This package has no purpose except to perform registration of multihashes. | ||
|
||
It is meant to be used as a side-effecting import, e.g. | ||
|
||
import ( | ||
_ "github.com/multiformats/go-multihash/register/murmur3" | ||
) | ||
|
||
This package registers multihashes for murmur3 | ||
*/ | ||
package murmur3 | ||
|
||
import ( | ||
"hash" | ||
|
||
multihash "github.com/multiformats/go-multihash/core" | ||
"github.com/spaolacci/murmur3" | ||
) | ||
|
||
func init() { | ||
multihash.Register(multihash.MURMUR3X64_64, func() hash.Hash { return murmur64{murmur3.New64()} }) | ||
} | ||
|
||
// A wrapper is needed to export the correct size, because murmur3 incorrectly advertises Hash64 as a 128bit hash. | ||
type murmur64 struct { | ||
hash.Hash64 | ||
} | ||
|
||
func (murmur64) BlockSize() int { | ||
return 1 | ||
Comment on lines
+30
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this looks slightly funny. I can't really fathom any harm to it, though. ... but I went on a splunk anyway, and I'd say 16 is probably an accurate number. citation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'm trying to stay with what it would report natively: https://github.com/spaolacci/murmur3/blob/539464a789e9b9f01bc857458ffe2c5c1a2ed382/murmur.go#L31 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. huh. Remains weird to me that they said it that way, but okay. |
||
} | ||
|
||
func (x murmur64) Size() int { | ||
return 8 | ||
} | ||
|
||
func (x murmur64) Sum(digest []byte) []byte { | ||
return x.Hash64.Sum(digest) | ||
} |
+11 −0 | .github/workflows/validate.yml | |
+0 −9 | .travis.yml | |
+31 −3 | README.md | |
+485 −442 | table.csv | |
+41 −8 | validate.py |
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: maybe this type name should be as verbose as the constants became, for consistency?