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

Commit

Permalink
Do not use unkeyed struct declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
hsanjuan committed Mar 2, 2022
1 parent 4b8b354 commit d6b4f4b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions arc_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@ func (b *arccache) Has(ctx context.Context, k cid.Cid) (bool, error) {

func (b *arccache) GetSize(ctx context.Context, k cid.Cid) (int, error) {
if !k.Defined() {
return -1, ipld.ErrNotFound{k}
return -1, ipld.ErrNotFound{Cid: k}
}

key := cacheKey(k)

if has, blockSize, ok := b.queryCache(key); ok {
if !has {
// don't have it, return
return -1, ipld.ErrNotFound{k}
return -1, ipld.ErrNotFound{Cid: k}
}
if blockSize >= 0 {
// have it and we know the size
Expand Down Expand Up @@ -180,15 +180,15 @@ func (b *arccache) View(ctx context.Context, k cid.Cid, callback func([]byte) er
}

if !k.Defined() {
return ipld.ErrNotFound{k}
return ipld.ErrNotFound{Cid: k}
}

key := cacheKey(k)

if has, _, ok := b.queryCache(key); ok && !has {
// short circuit if the cache deterministically tells us the item
// doesn't exist.
return ipld.ErrNotFound{k}
return ipld.ErrNotFound{Cid: k}
}

b.lock(key, false)
Expand All @@ -214,13 +214,13 @@ func (b *arccache) View(ctx context.Context, k cid.Cid, callback func([]byte) er

func (b *arccache) Get(ctx context.Context, k cid.Cid) (blocks.Block, error) {
if !k.Defined() {
return nil, ipld.ErrNotFound{k}
return nil, ipld.ErrNotFound{Cid: k}
}

key := cacheKey(k)

if has, _, ok := b.queryCache(key); ok && !has {
return nil, ipld.ErrNotFound{k}
return nil, ipld.ErrNotFound{Cid: k}
}

b.lock(key, false)
Expand Down
6 changes: 3 additions & 3 deletions bloom_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (b *bloomcache) Has(ctx context.Context, k cid.Cid) (bool, error) {

func (b *bloomcache) GetSize(ctx context.Context, k cid.Cid) (int, error) {
if has, ok := b.hasCached(k); ok && !has {
return -1, ipld.ErrNotFound{k}
return -1, ipld.ErrNotFound{Cid: k}
}

return b.blockstore.GetSize(ctx, k)
Expand All @@ -173,14 +173,14 @@ func (b *bloomcache) View(ctx context.Context, k cid.Cid, callback func([]byte)
}

if has, ok := b.hasCached(k); ok && !has {
return ipld.ErrNotFound{k}
return ipld.ErrNotFound{Cid: k}
}
return b.viewer.View(ctx, k, callback)
}

func (b *bloomcache) Get(ctx context.Context, k cid.Cid) (blocks.Block, error) {
if has, ok := b.hasCached(k); ok && !has {
return nil, ipld.ErrNotFound{k}
return nil, ipld.ErrNotFound{Cid: k}
}

return b.blockstore.Get(ctx, k)
Expand Down

0 comments on commit d6b4f4b

Please sign in to comment.