style(blockservice) s/Remote/Exchange
License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
Brian Tiger Chow committed
Nov 26, 2014 at 17:01 UTC
43ff3c5040128a195bf24c5ae83cab6a80877b9b
1 file changed
+7
-7
blockservice/blockservice.go
+7
-7
@@ -25,7 +25,7 @@ var ErrNotFound = errors.New("blockservice: key not found")
25
type BlockService struct {
26
// TODO don't expose underlying impl details
27
Blockstore blockstore.Blockstore
28
- Remote exchange.Interface
28
+ Exchange exchange.Interface
29
}
30
31
// NewBlockService creates a BlockService with given datastore instance.
@@ -36,7 +36,7 @@ func New(bs blockstore.Blockstore, rem exchange.Interface) (*BlockService, error
36
if rem == nil {
37
log.Warning("blockservice running in local (offline) mode.")
38
}
39
- return &BlockService{Blockstore: bs, Remote: rem}, nil
39
+ return &BlockService{Blockstore: bs, Exchange: rem}, nil
40
}
41
42
// AddBlock adds a particular block to the service, Putting it into the datastore.
@@ -66,9 +66,9 @@ func (s *BlockService) AddBlock(b *blocks.Block) (u.Key, error) {
66
67
// TODO this operation rate-limits blockservice operations, we should
68
// consider moving this to an sync process.
69
- if s.Remote != nil {
69
+ if s.Exchange != nil {
70
ctx := context.TODO()
71
- err = s.Remote.HasBlock(ctx, b)
71
+ err = s.Exchange.HasBlock(ctx, b)
72
}
73
return k, err
74
}
@@ -82,9 +82,9 @@ func (s *BlockService) GetBlock(ctx context.Context, k u.Key) (*blocks.Block, er
82
return block, nil
83
// TODO be careful checking ErrNotFound. If the underlying
84
// implementation changes, this will break.
85
- } else if err == ds.ErrNotFound && s.Remote != nil {
85
+ } else if err == ds.ErrNotFound && s.Exchange != nil {
86
log.Debug("Blockservice: Searching bitswap.")
87
- blk, err := s.Remote.GetBlock(ctx, k)
87
+ blk, err := s.Exchange.GetBlock(ctx, k)
88
if err != nil {
89
return nil, err
90
}
@@ -117,7 +117,7 @@ func (s *BlockService) GetBlocks(ctx context.Context, ks []u.Key) <-chan *blocks
117
}
118
}
119
120
- rblocks, err := s.Remote.GetBlocks(ctx, misses)
120
+ rblocks, err := s.Exchange.GetBlocks(ctx, misses)
121
if err != nil {
122
log.Errorf("Error with GetBlocks: %s", err)
123
return