Replace constant hashmaps with const fn #1631
Labels
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
Description
Currently there are some constants defined as hashmaps in
rust-fil-proofs/filecoin-proofs/src/constants.rs
Lines 51 to 120 in 4ff161d
RwLock
which is only needed for prodbench, which I even don't know whether anyone is still using/if it still works. So witherprodbench
can be removed and if not, I think it doesn't really need the feature of being able to add custom constants.This means that those hashmaps could be replaces with a constant functions. E.g.
POREP_PARTITIONS
could be replaces with something like:The advantage is that we don't need a
lazy_static
, but also that if you pass in an unsupported size, it will panic at compile-time, not at runtime.This change would also remove a lot of boilerplate code. If you search for
POREP_PARTITIONS
, you'll find many occurrences of:which could be replaced by
porep_partitions(SECTOR_SIZE_2_KIB)
.Acceptance criteria
The hashmaps mentioned above are replaced by const functions.
Risks + pitfalls
Those are part of the public API, so crates like
filecoin-proofs-api
would also need to be adapted.Where to begin
Change one of those hashmaps to a const fn and get things compiled.
The text was updated successfully, but these errors were encountered: