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

Commit

Permalink
feat: fast-path for PutMany, falling back to Put for single block call (
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelMure committed May 6, 2022
1 parent f5e3cdb commit e4da93c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions blockstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,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

0 comments on commit e4da93c

Please sign in to comment.