Skip to content
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

PoE switched from FNV to murmur hash #5

Open
beevik opened this issue Dec 3, 2023 · 0 comments
Open

PoE switched from FNV to murmur hash #5

beevik opened this issue Dec 3, 2023 · 0 comments

Comments

@beevik
Copy link

beevik commented Dec 3, 2023

In league 3.21, PoE appears to have changed their name hashing algorithm from FNV to MurmurHash. I added this function to index.go and started calling it instead of FNV. This seemts to have fixed the incompatibility.

func murmurHash(path string) uint64 {
	const (
		seed    = 0x1337b33f
		initial = 0xc6a4a7935bd1e995
		r       = 47
	)

	path = strings.ToLower(path)
	path = strings.TrimRight(path, "/\\")
	b := []byte(path)
	m := uint64(initial)
	h := seed ^ (uint64(len(b)) * m)
	for len(b) >= 8 {
		k := binary.LittleEndian.Uint64(b[:8])
		b = b[8:]
		k *= m
		k = (k ^ (k >> r)) * m
		h = (h ^ k) * m
	}

	if len(b) > 0 {
		k := uint64(0)
		for i := len(b) - 1; i >= 0; i-- {
			k = (k << 8) | uint64(b[i])
		}
		h = (h ^ k) * m
	}

	h = (h ^ (h >> r)) * m
	h = h ^ (h >> r)
	return h
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant