Skip to content

Commit 0bf8c2a

Browse files
authored
feat: fast-path for PutMany, falling back to Put for single block call (ipfs#97)
This commit was moved from ipfs/go-ipfs-blockstore@e4da93c
1 parent 8dceb79 commit 0bf8c2a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

blockstore/blockstore.go

+5
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@ func (bs *blockstore) Put(ctx context.Context, block blocks.Block) error {
178178
}
179179

180180
func (bs *blockstore) PutMany(ctx context.Context, blocks []blocks.Block) error {
181+
if len(blocks) == 1 {
182+
// performance fast-path
183+
return bs.Put(ctx, blocks[0])
184+
}
185+
181186
t, err := bs.datastore.Batch(ctx)
182187
if err != nil {
183188
return err

0 commit comments

Comments
 (0)