Coder Social home page Coder Social logo

pinnaculum / py-multiformats-cid Goto Github PK

View Code? Open in Web Editor NEW
6.0 6.0 1.0 112 KB

Self-describing content-addressed identifiers for distributed systems implementation in Python (fork of the deprecated ipld/py-cid)

License: MIT License

Makefile 9.23% Python 90.77%

py-multiformats-cid's Introduction

I don't use this platform anymore (only keeping a few mirror repos around). All my opensource work is done on GitLab as @cipres.

py-multiformats-cid's People

Contributors

bh2smith avatar biglep avatar dependabot[bot] avatar dhruvbaldawa avatar filips123 avatar oberstet avatar pyup-bot avatar skorokithakis avatar veqtor avatar vmx avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

bh2smith

py-multiformats-cid's Issues

Wrong Encoded version of the raw representation of the CID object

  • CID (Content IDentifier) version:
  • Python version: 3.9
  • Operating System: Debian

Description

I have implemented this function to return a CIDv1 object.

def encodeReference(ref: Union[str, Reference], codec: str, version: Optional[int] = 1) -> CIDv1:
    """
    create a new CID object by default and make it CIDv1.
    """
    hash_bytes = hexToBytes(ref)

    return CIDv1(codec, keccak(hash_bytes))

# use case
>>> test_reference = "ca6357a08e317d15ec560fef34e4c45f8f19f01c372aa70f1da72bfa7f1a4338"
>>> cid = swarm_cid.encodeReference(test_reference, "swarm-manifest" 1)
>>> str(cid)

What I Did

# Expected output
bah5acgzazjrvpieogf6rl3cwb7xtjzgel6hrt4a4g4vkody5u4v7u7y2im4a

# Got
bah5adiu4n2h72bxilg6iiqulrx2m3nuyzliwpyvhmidskdedbpevg54o

Add Types!

Mypy complains and I have to silence it like this (which is not ideal).

from multiformats_cid import from_bytes  # type: ignore

If the project is already typed, then it should be as easy as adding an empty file called py.typed to the base module.

and adding this to setup configuration:

[options.package_data]
cid = py.typed

It appears I posted the issue in the wrong place:

multiformats/cid#56

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.