Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

feat: fast-path for PutMany, falling back to Put for single block call #97

Merged
merged 1 commit into from
May 6, 2022
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
5 changes: 5 additions & 0 deletions blockstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ func (bs *blockstore) Put(ctx context.Context, block blocks.Block) error {
}

func (bs *blockstore) PutMany(ctx context.Context, blocks []blocks.Block) error {
if len(blocks) == 1 {
// performance fast-path
return bs.Put(ctx, blocks[0])
}

t, err := bs.datastore.Batch(ctx)
if err != nil {
return err
Expand Down