@cryptotaxi247 / kubo / commits / 61b481628

blockstore: cleanup the style removing some mess from the refactor

License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

Jakub Sztandera committed Aug 3, 2016 at 13:54 UTC 61b481628ad6b8779fa49ba13dd5e41bcca4982a
1 file changed +7 -9
blocks/blockstore/arc_cache.go
+7 -9
@@ -30,30 +30,28 @@ func (b *arccache) DeleteBlock(k key.Key) error {
30 b.arc.Remove(k) // Invalidate cache before deleting.
31 err := b.blockstore.DeleteBlock(k)
32 switch err {
33 - case nil:
34 - b.arc.Add(k, false)
35 - case ds.ErrNotFound, ErrNotFound:
33 + case nil, ds.ErrNotFound, ErrNotFound:
34 b.arc.Add(k, false)
35 + return nil
36 default:
37 return err
38 }
40 - return nil
39 }
40
41 // if ok == false has is inconclusive
42 // if ok == true then has respons to question: is it contained
43 func (b *arccache) hasCached(k key.Key) (has bool, ok bool) {
44 if k == "" {
47 - // Return cache invalid so call to blockstore
48 - // in case of invalid key is forwarded deeper
45 + // Return cache invalid so the call to blockstore happens
46 + // in case of invalid key and correct error is created.
47 return false, false
48 }
49 +
50 h, ok := b.arc.Get(k)
51 if ok {
53 - return h.(bool), ok
54 - } else {
55 - return false, false
52 + return h.(bool), true
53 }
54 + return false, false
55 }
56
57 func (b *arccache) Has(k key.Key) (bool, error) {