Commit ead913a2 authored by hannahhoward's avatar hannahhoward

refactor(cidlink): use interface rather than concrete type

Use interface rather than concrete type for byte buffer checker
parent ec8dd23e
......@@ -19,6 +19,11 @@ type Link struct {
cid.Cid
}
// byteAccessor is a reader interface that can access underlying bytes
type byteAccesor interface {
Bytes() []byte
}
func (lnk Link) Load(ctx context.Context, lnkCtx ipld.LinkContext, na ipld.NodeAssembler, loader ipld.Loader) error {
// Open the byte reader.
r, err := loader(lnk, lnkCtx)
......@@ -32,7 +37,7 @@ func (lnk Link) Load(ctx context.Context, lnkCtx ipld.LinkContext, na ipld.NodeA
}
var hasherBytes []byte
var decodeErr error
byteBuf, ok := r.(*bytes.Buffer)
byteBuf, ok := r.(byteAccesor)
if ok {
hasherBytes = byteBuf.Bytes()
decodeErr = mcDecoder(na, r)
......
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