Don't lock in Get

This commit is contained in:
Aayush Rajasekaran 2022-01-12 16:04:47 -05:00 committed by Jennifer Wang
parent 4ec8fbf1ff
commit 107f80274c

View File

@ -152,8 +152,6 @@ func (bs *AutobatchBlockstore) Shutdown(ctx context.Context) error {
} }
func (bs *AutobatchBlockstore) Get(ctx context.Context, c cid.Cid) (block.Block, error) { func (bs *AutobatchBlockstore) Get(ctx context.Context, c cid.Cid) (block.Block, error) {
bs.stateLock.Lock()
defer bs.stateLock.Unlock()
// may seem backward to check the backingBs first, but that is the likeliest case // may seem backward to check the backingBs first, but that is the likeliest case
blk, err := bs.backingBs.Get(ctx, c) blk, err := bs.backingBs.Get(ctx, c)
if err == nil { if err == nil {
@ -174,7 +172,7 @@ func (bs *AutobatchBlockstore) Get(ctx context.Context, c cid.Cid) (block.Block,
return v, nil return v, nil
} }
return nil, ErrNotFound return bs.Get(ctx, c)
} }
func (bs *AutobatchBlockstore) DeleteBlock(context.Context, cid.Cid) error { func (bs *AutobatchBlockstore) DeleteBlock(context.Context, cid.Cid) error {