1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Copyright 2021-2022 Parity Technologies (UK) Ltd.
// This file is dual-licensed as Apache-2.0 or MIT.

use std::hash::BuildHasherDefault;

#[derive(Default)]
pub struct IdentityKeyHash(u64);
pub type IdentityBuildHasher = BuildHasherDefault<IdentityKeyHash>;

impl std::hash::Hasher for IdentityKeyHash {
	fn finish(&self) -> u64 {
		self.0
	}

	fn write(&mut self, bytes: &[u8]) {
		self.0 = u64::from_le_bytes((&bytes[0..8]).try_into().unwrap())
	}
}