fix blockservice error ignorance
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
Jeromy committed
Sep 4, 2015 at 15:41 UTC
4d8eddcebccce65bcd9c08edc743c84c2f9db68d
1 file changed
+9
-3
blockservice/blockservice.go
+9
-3
@@ -96,19 +96,25 @@ func (s *BlockService) GetBlock(ctx context.Context, k key.Key) (*blocks.Block,
96
block, err := s.Blockstore.Get(k)
97
if err == nil {
98
return block, nil
99
+ }
100
+
101
+ if err == blockstore.ErrNotFound && s.Exchange != nil {
102
// TODO be careful checking ErrNotFound. If the underlying
103
// implementation changes, this will break.
101
- } else if err == blockstore.ErrNotFound && s.Exchange != nil {
104
log.Debug("Blockservice: Searching bitswap.")
105
blk, err := s.Exchange.GetBlock(ctx, k)
106
if err != nil {
107
return nil, err
108
}
109
return blk, nil
108
- } else {
109
- log.Debug("Blockservice GetBlock: Not found.")
110
+ }
111
+
112
+ log.Debug("Blockservice GetBlock: Not found.")
113
+ if err == blockstore.ErrNotFound {
114
return nil, ErrNotFound
115
}
116
+
117
+ return nil, err
118
}
119
120
// GetBlocks gets a list of blocks asynchronously and returns through