Mam dla hasza transakcji i indeksu znaleźć adres i kwotę (Bitcoiny).
Czy zrobić tak?
struct Y
{
uint8_t hash[32];
uint32_t index;
};
struct Z
{
char address[36];
uint64_t amount;
};
struct hash_Y {
//http://isthe.com/chongo/tech/comp/fnv/
static size_t FNV_1(const uint8_t *bytes, size_t count)
{
size_t hash, FNV_prime;
if (sizeof(size_t) > 4)
{
hash = 14695981039346656037;
FNV_prime = 1099511628211;
}
else
{
hash = 2166136261;
FNV_prime = 16777619;
}
if (count > 0)
for (size_t i = 0; i < count; i++)
{
hash *= FNV_prime;
hash ^= bytes[i];
}
return hash;
}
size_t operator()(const Y &Y) const {
return FNV_1(y.hash, sizeof(y.hash)) ^ FNV_1((uint8_t*)&y.index, sizeof(y.index));
}
};
std::unordered_map<Y, Z, hash_Y> my_map;