ChainSafe / forest

🌲 Rust Filecoin Node Implementation
https://forest.chainsafe.io
Apache License 2.0
630 stars 152 forks source link

Cid Prefix to bytes #428

Closed austinabell closed 4 years ago

austinabell commented 4 years ago

Task summary

Prefix to bytes generation is needed for Graphsync

Use go as a reference: https://github.com/ipfs/go-cid/blob/master/cid.go#L569

Currently the Prefix type in cid crate does not include (mh_len) because it is very unhelpful and requires some data to be arbitrarily hashed to be determined, so I think the easiest solution would be to just add a function on top of the Cid type to generate the prefix bytes, but if the prefix needs to be reused and the mh_len is needed, that may need to be added back.

Specification reference

Other information and links

vmx commented 4 years ago

Please see https://github.com/rs-ipfs/rust-ipfs/blob/7799d888f68ab38d6b771c895b23f5cab0e61fa5/bitswap/src/prefix.rs for an implementation.