Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions store.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (s *BasicIpldStore) Put(ctx context.Context, v interface{}) (cid.Cid, error

var expCid cid.Cid
if c, ok := v.(cidProvider); ok {
expCid := c.Cid()
expCid = c.Cid()
pref := expCid.Prefix()
mhType = pref.MhType
mhLen = pref.MhLength
Expand Down Expand Up @@ -133,15 +133,15 @@ func (s *BasicIpldStore) Put(ctx context.Context, v interface{}) (cid.Cid, error
return cid.Undef, err
}

if err := s.Blocks.Put(ctx, blk); err != nil {
return cid.Undef, err
}

blkCid := blk.Cid()
if expCid != cid.Undef && blkCid != expCid {
return cid.Undef, fmt.Errorf("your object is not being serialized the way it expects to")
}

if err := s.Blocks.Put(ctx, blk); err != nil {
return cid.Undef, err
}

return blkCid, nil
}

Expand All @@ -150,15 +150,15 @@ func (s *BasicIpldStore) Put(ctx context.Context, v interface{}) (cid.Cid, error
return cid.Undef, err
}

if err := s.Blocks.Put(ctx, nd); err != nil {
return cid.Undef, err
}

ndCid := nd.Cid()
if expCid != cid.Undef && ndCid != expCid {
return cid.Undef, fmt.Errorf("your object is not being serialized the way it expects to")
}

if err := s.Blocks.Put(ctx, nd); err != nil {
return cid.Undef, err
}

return ndCid, nil
}

Expand Down