提交 f13506c1 作者: Jakub Sztandera

blocks/blockstore: style cleanup of bloomcache

License: MIT
Signed-off-by: 's avatarJakub Sztandera <kubuxu@protonmail.ch>
上级 e92e6662
......@@ -76,32 +76,36 @@ func (b *bloomcache) DeleteBlock(k key.Key) error {
b.arc.Remove(k) // Invalidate cache before deleting.
err := b.blockstore.DeleteBlock(k)
if err == nil {
switch err {
case nil:
b.arc.Add(k, false)
} else if err == ds.ErrNotFound || err == ErrNotFound {
case ds.ErrNotFound, ErrNotFound:
b.arc.Add(k, false)
return ErrNotFound
default:
return err
}
return err
return nil
}
// if ok == false has is inconclusive
// if ok == true then has respons to question: is it contained
func (b *bloomcache) hasCached(k key.Key) (has bool, ok bool) {
if k == "" {
return true, true
// Return cache invalid so call to blockstore
// in case of invalid key is forwarded deeper
return false, false
}
if b.BloomActive() {
blr := b.bloom.HasTS([]byte(k))
if blr == false { // not contained in bloom is only conclusive answer bloom gives
return blr, true
return false, true
}
}
h, ok := b.arc.Get(k)
if ok {
return h.(bool), ok
} else {
return false, ok
return false, false
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论