Generic Modules/Utils
See original GitHub issueBefore 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 https://github.com/ipfs/py-ipfs/issues/21#issuecomment-158019175 for more info):
- PeerID
- PeerInfo
- multihash
- multihashing (optional,
pymultihash
delegates this mostly tohashlib
)- specs: ???
- js impl: https://github.com/jbenet/js-multihashing
- multiaddr
- specs: https://github.com/jbenet/multiaddr
- go impl: https://github.com/jbenet/go-multiaddr
- js impl: https://github.com/jbenet/js-multiaddr
- py impl: https://github.com/sbuss/py-multiaddr
- multistream
- multicodec
- ipld
- specs: ???
- discussion: https://github.com/ipfs/go-ipld/issues/8
- go impl: https://github.com/ipfs/go-ipld
- py impl: https://github.com/ipld/py-ipld-dag
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.
Issue Analytics
- State:
- Created 8 years ago
- Comments:23 (18 by maintainers)
Top Results From Across the Web
Module: utils.generics — IPython 8.7.0 documentation
Module : utils.generics ¶. Generic functions for extending IPython. 2 Functions¶. IPython.utils.generics.inspect_object(obj)¶. Called when you do obj?
Read more >Module: utils.generics — IPython 3.2.1 documentation
Custom completer dispatching for python objects. Parameters: obj : object. The object to complete. prev_completions : list. List of ...
Read more >Generic Utils - Keras 1.2.2 Documentation
Retrieves a class or function member of a module. First checks _GLOBAL_CUSTOM_OBJECTS for module_name , then checks module_params . Arguments. identifier: the ...
Read more >Using and developing module utilities - Ansible Documentation
Generic utilities (shared code used by many different kinds of modules) live in the main ansible/ansible codebase, in the common subdirectory or in...
Read more >habitat.utils.dynamicloader: a generic dynamic module loader
A generic dynamic python module loader. The main function to call is load(). In addition, several functions to quickly test the loaded object...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
For
hashlib
compatibility we only need to provide a single class, and in my opinion it still makes sense to provide some additional functionality related with multihash in the same module.For instance (and taking much inspiration from the examples above), a single
multihash.py
module may be created that provides ahashlib
-compatible class (hash
) and a structured utility class (Multihash
) in the same place:The
Multihash
class above could well be implemented as anamedtuple
for memory savings. I used anEnum
for the hash function as a comfortable and compact way to have the function code and name together, although numbers and strings may be accepted as well:Top-level utility functions may be defined to use encoded multihash strings straight away instead of
Multihash
(e.g.mh_digest == b'\x11\x14\x0b...'
andmh_string == '5dqx...'
:But I don’t much see the point of these last functions.