turbofish-org / orga

State machine engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hash caching and shared set hash functions

mappum opened this issue · comments

We will be storing read/write keys in sets and doing intersection/union operations on them often. Since std::collections::HashSet uses a random hash function per-instance by default to prevent DoS attacks, that means we have to hash each key a significant number of times.

It would be more efficient to create sets which share a hash function, and cache the computed hash somewhere (possibly inside the Key struct, see #8).

We can still randomize the hash function periodically to prevent DoS (e.g. once per block, with each node picking a random seed since it doesn't need to be deterministic).

This feature could live in its own crate, named hashcache.