Bitcoin full node and query server

Mar 7, 2025

View in context in the libbitcoin Slack #general mirror.

evoskuil19:25
the hashmap head. the hash function for the point table is a std::hash combine of the tx.hash and the index. the hash of the tx.hash is the first 4 bytes.
evoskuil19:46
This is a typical good hash function. It was dramatically less efficient than our "unique hash" for sha values.
// Objectives: deterministic, uniform distribution, efficient computation.
INLINE constexpr size_t djb2_hash(const data_slice& data) NOEXCEPT
{
    // Nothing special here except that it tested well against collisions.
    auto hash = 5381_size;

    // Efficient sum of ((hash * 33) + byte) for all bytes.
    for (const auto byte: data)
        hash = (shift_left(hash, 5_size) + hash) + byte;

    return hash;
}