File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed
Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -247,16 +247,15 @@ func FromBinary(v string) Multihash {
247247 return Multihash {v }
248248}
249249
250- // Parts returns the components of the Multihash (Code, Name, Digest)
251- func (m Multihash ) Parts () (uint64 , int , string ) {
252- // Note: no need to check for errors as the New method guarantees
250+ // Parts returns the components of the Multihash: Code & Digest
251+ // The length part can be derived from the Digest length
252+ func (m Multihash ) Parts () (uint64 , string ) {
253+ // Note: no need to check for errors as the FromBinary method guarantees
253254 // the string can be parsed
254- i := 0
255- codec , l := strbinary .Uvarint (m .s )
256- i += l
257- digestLen , l := strbinary .Uvarint (m .s [i :])
258- i += l
259- return codec , int (digestLen ), m .s [i :]
255+ codec , i := strbinary .Uvarint (m .s )
256+ // skip over Length component, no need to read it
257+ i += strbinary .UvarintLen (m .s [i :])
258+ return codec , m .s [i :]
260259}
261260
262261// Cast casts a buffer onto a multihash, and returns an error
You can’t perform that action at this time.
0 commit comments