-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generic Modules/Utils #23
Comments
multicodec, too. ipld as well. On Thu, Nov 19, 2015 at 8:02 PM Andrew Stocker [email protected]
|
@jbenet thanks |
Regarding the multihash/multihashing split, it appears our discussion in #13 is now obsolete. We agreed on using a multihash implementation that followed the Python hashlib API, but current favourite JulienPalard's is more of a multihash_ing_ implementation, in that it exposes a high level Python-hashlib-like interface to create multihash values and hexdigests, but doesn't implement the low level go-multihash/js-multihash interface. The multihash/multihashing split seems also very useful if we are to share as much of the testing as possible, maybe through sharness or some other platform-independent system. This is my suggestion: Multihashing:
Multihash:
If people agree to the above points, I could do this work myself. I'm already doing it on Elixir. @amstocker: I'll look into your multiaddr starter over the weekend. Maybe we can meet on IRC after the libp2p hangout, which I plan to lurk on. |
I can't completly agree, if we're diverging from On the other hand, I don't think it's the responsibility of an hashlib to encode (in any bases like base58). I mean, one may want to use hashlib but don't care about encoding in base58, and one may use a base58 encoder without needing hashlib. |
I don't think you're limited to one "drop in replacement" interface. What I often do is write the interface I want, and then write another object that wraps it to provide some other useful interface.
Or something more concise :) |
@candeira that sgtm. If the 2 modules thing sounds cumbersome, another option is to use subpackages in python. I prefer super modular things (hence breaking it up into two modules) but the py and go communities don't in general. |
@JulienPalard: I don't know that we are talking about the same thing when we mention encoding. It has to do with the view of whether a separation is needed between the functionality of multihash and of multihashing.
Your However, after reading about the difference between
As to the necessity of a In short, having a I think there is a design that can please everyone, and I plan to offer an implementation soon. Here it is:
This fulfills everybody's needs and requirements:
@jbenet I guess you were using 'modules' in a Go sense. This proposal suggests having one single python package with three independent Python modules, ie three .py files. I don't see any reason to split it further. |
I still don't get the difference between |
It looks like I miseed your message #23 (comment), so I'm re-replying. I still think that On the other hand I'm aware that sticking on a pure But, adding a I still agree that we need a base58 library, but not only for the hasing representation, probably for some other representations too. It all boils up to choosing between:
and
As I can understand it, A long message, to propose almost nothing better, that's bad. real bad, sorry. But before choosing names, we have to synchronize on what we want those two differents libs to do (what reponsibilities do they get). We're not simply copying a javascript implementation. |
I think that the first one makes a lot more sense to me, but I would change import multihash
from base58 import b58encode, b58decode
print(b58encode(multihash.hash(...))) In general I think we should have these basic modules:
and then these modules for multihash:
All the multihash modules can be part of |
For For instance (and taking much inspiration from the examples above), a single
The
Top-level utility functions may be defined to use encoded multihash strings straight away instead of
But I don't much see the point of these last functions. |
After reviewing the previous proposals I've noticed that it may not make sense to implement multihash as a
|
Ongoing implementation of the proposal just above in https://github.com/ivilata/pymultihash. |
We're overlapping, ivilata. My ongoing implementation is at https://github.com/candeira/py-multihash. |
Hi @candeira, my implementation is based on my proposal above, which departs from your multihash/multihashing proposal to focus on something more pythonic (to my taste, of course!). It is currently only lacking some error checks and an introductory module docstring with some comprehensive usage examples beyond function doctests. I hope that the complete doc can offer a better feeling for the module and help us decide which parts to reuse, merge or drop. No worries if the whole thing is merged or dropped altogether. |
I've uploaded pymultihash to PyPi. It's feature complete, with some testing (using doctests) and a pretty complete tutorial in the package docstring (which I'm working to put through Sphinx). You're very welcome to have a look at it and give your opinions, thanks! Edit: docs available in ReadTheDocs. |
@ivilata this is really awesome!! |
Really good! I'm still struggling to find time to finish mine. More to come. |
Thanks! In general I'd like to make a case for not trying to mimic the Go or JS and go for something more pythonic where possible. |
I found another multihash implementation: https://github.com/kalmi/py-multihash |
@Fak3 YAYYYYYYYYYY ! #irony |
@Fak3 there's a few out there but afaik the one made by @ivilata is the most fleshed out: https://github.com/ivilata/pymultihash |
There is an additional multiaddr implementation by @sbuss present as well: https://github.com/sbuss/py-multiaddr. |
Before moving on to the rest of libp2p and py-ipfs, we should look at the required generic utilities and determine which existing implementation we want to use, or if there isn't one, who wants to work on it. Here is what we need (see #21 (comment) for more info):
pymultihash
delegates this mostly tohashlib
)I know we already have several multihash implementations, and I hacked together a multiaddr implementation that could use some love. If anyone has already worked on any of these or is interested on working on any of them, please comment here. Also if anyone has anymore links to references or specs for the generic modules, post them here.
The text was updated successfully, but these errors were encountered: