Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

fix: correctly encode multihashes with serde #7

Merged
merged 1 commit into from
Oct 15, 2021

Conversation

Stebalien
Copy link
Contributor

The number of digest bytes written needs to match the size.

See the upstream issue here: multiformats/rust-multihash#140

The one change is to not allocate.

The number of digest bytes written needs to match the size.

See the upstream issue here: multiformats/rust-multihash#140

All credit goes to @koushiro. My one change is to not allocate.
@Stebalien
Copy link
Contributor Author

Note: I'm not entirely sure if this is the correct fix. At a minimum, we shouldn't be writing the extra bytes. But I'm not sure if just spitting out the buffer without calling encode is correct.

@Stebalien
Copy link
Contributor Author

And it's definitely a breaking change.

@johnchandlerburnham johnchandlerburnham merged commit ca3f476 into argumentcomputer:main Oct 15, 2021
@johnchandlerburnham
Copy link
Member

Looking at the upstream issue, this makes sense to me, and resolves some of the confusion I had around truncation. Not 100% sure it's completely right either, but it seems more right than what exists currently, so in the interest of moving fast I've merged it.

Do the other multihash implementations do truncation correctly? Would be useful to compare if so

@Stebalien
Copy link
Contributor Author

Do the other multihash implementations do truncation correctly? Would be useful to compare if so

Yes. My concern here is whether or not this is supposed to be encoded as a multihash or as something else. Specifically, should the digest be length-prefixed, or written as raw bytes.

@johnchandlerburnham
Copy link
Member

I'm pretty sure it should be encoded as a multihash, as per multiformats/multihash#133

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants