Consider API cleanup
- Dominant language
- Go
- Stars
- 122
- Forks
- 53
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 5
Description
> This method cannot be implemented outside of the package - therefore you need to fork repository to add custom `Hasher` implementation. I think, entire idea behind `Hasher` interface was to enable easy replacement when nmt is used as library.
>
> Both interface (type) and method has to be visible so they could be implemented. I would also suggest putting it next to `Hasher` interface definition.
_Originally posted by @tzdybal in https://github.com/celestiaorg/nmt/pull/305#discussion_r2373487307_
As discussed in PR, there is some space for interface cleanup.
Currently API is a bit confusing, because you can configure "ReuseBuffers", but you can't create custom `Hasher` implementation that will reuse buffers (yet you can create own hasher implementation in general).
The comments in the code suggest `Hasher` interface is mostly used for tests, and for production it's not recommended to use anything other than `NmtHasher` - if it's the case, we should "hide" `Hasher` interface.
This is obviously a breaking change and we need to release a new version.
We can add `Reset` function to `Hasher` (or `hasher`) (typical for hash functions of any sort) so we can easily reset implementation state as needed, without casting, etc.
Contributor guide
Research direction
Start by locating the Hasher interface, NmtHasher, and ReuseBuffers configuration, then review PR #305's discussion. Define the intended public API, including whether Reset is required, and verify the resulting breaking-change and release requirements before implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, backend-api-design
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100