-
Notifications
You must be signed in to change notification settings - Fork 51
Description
It might make sense to export the nmt-specific hashing currently "hidden" in the internal package:
https://github.com/lazyledger/nmt/tree/master/internal
This particularly makes sense in the light of the IPLD plugin. Instead of redefining the logic when adding a custom hasher (see: celestiaorg/celestia-core#155, https://github.com/lazyledger/go-multihash/pull/1 and in particular this (wip) code), we could just import the hashers from here instead. Besides exporting it would require some minor changes to the hasher api to easily match that of HashFunc.
The main benefit of doing this is that the logic is defined in one place only. As a result, we don't need to keep two implementations in sync. Furthermore, we do not need to make sure (e.g. via unit tests) that the hasher used in the nmt internally matches the one used to compute the Sum of an IPLD block (as the registered custom multihasher just imports the code from here).
Note to use the hashers as described above, ideally, we would register two multihashers instead of one (and looking at the prefix as we do currently).