Skip to content

Commit

Permalink
blocks/blockstore: improve logic a bit
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
  • Loading branch information
Kubuxu committed Jul 8, 2016
1 parent 8f8de2d commit c33aed6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions blocks/blockstore/caching.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func CachedBlockstore(bs GCBlockstore,
if ctx == nil {
ctx = context.TODO() // For tests
}
cbs = bs

if opts.HasBloomFilterSize < 0 || opts.HasBloomFilterHashes < 0 ||
opts.HasARCCacheSize < 0 || opts.BlockARCCacheSize < 0 {
Expand All @@ -35,8 +36,10 @@ func CachedBlockstore(bs GCBlockstore,
if opts.HasBloomFilterSize != 0 && opts.HasBloomFilterHashes == 0 {
return nil, errors.New("bloom filter hash count can't be 0 when there is size set")
}
cbs, err = bloomCached(bs, ctx, opts.HasBloomFilterSize, opts.HasBloomFilterHashes,
opts.HasARCCacheSize)
if opts.HasBloomFilterSize != 0 {
cbs, err = bloomCached(cbs, ctx, opts.HasBloomFilterSize, opts.HasBloomFilterHashes,
opts.HasARCCacheSize)
}

return cbs, err
}

0 comments on commit c33aed6

Please sign in to comment.