MCPcopy
hub / github.com/canopy-network/canopy / MemHash

Function MemHash

lib/util.go:1038–1041  ·  view source on GitHub ↗

MemHash is the hash function used by go map, it utilizes available hardware instructions(behaves as aeshash if aes instruction is available). NOTE: The hash seed changes for every process. So, this cannot be used as a persistent hash.

(data []byte)

Source from the content-addressed store, hash-verified

1036// as aeshash if aes instruction is available).
1037// NOTE: The hash seed changes for every process. So, this cannot be used as a persistent hash.
1038func MemHash(data []byte) uint64 {
1039 ss := (*stringStruct)(unsafe.Pointer(&data))
1040 return uint64(memhash(ss.str, 0, uintptr(ss.len)))
1041}
1042
1043// RandSlice is a helper to generate a random byte slice of the given size.
1044func RandSlice(byteSize uint64) []byte {

Callers 7

TestFuzzMultiSetFunction · 0.92
TestSetFunction · 0.92
TestDeleteFunction · 0.92
GetMethod · 0.92
updateMethod · 0.92
GetAccountMethod · 0.92
SetAccountMethod · 0.92

Calls 1

memhashFunction · 0.85

Tested by 3

TestFuzzMultiSetFunction · 0.74
TestSetFunction · 0.74
TestDeleteFunction · 0.74