Commit 89c40af3 authored by Eric Myhre's avatar Eric Myhre

Finish creating cid in cidlink.LinkBuilder.

Signed-off-by: default avatarEric Myhre <hash@exultant.us>
parent 57832ad7
......@@ -78,18 +78,16 @@ func (lb LinkBuilder) Build(ctx context.Context, lnkCtx ipld.LinkContext, node i
if !exists {
return nil, fmt.Errorf("no encoder registered for multicodec %d", lb.Prefix.MhType)
}
var hasher bytes.Buffer // multihash only exports bulk use, which is... really inefficient and should be fixed.
var hasher bytes.Buffer // multihash-via-cid only exports bulk use, which is... really inefficient and should be fixed.
w = io.MultiWriter(&hasher, w)
err = mcEncoder(node, w)
if err != nil {
return nil, err
}
hash, err := multihash.Sum(hasher.Bytes(), lb.Prefix.MhType, lb.Prefix.MhLength)
// FIXME finish making a CID out of this.
// the cid package is a maze of twisty little passages all alike and I don't honestly know what's up where why.
_ = hash
if err := commit(nil); err != nil {
return nil, err
cid, err := lb.Prefix.Sum(hasher.Bytes())
lnk := Link{cid}
if err := commit(lnk); err != nil {
return lnk, err
}
panic("TODO")
return lnk, nil
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment