提交 43ff3c50 作者: Brian Tiger Chow

style(blockservice) s/Remote/Exchange

License: MIT
Signed-off-by: 's avatarBrian Tiger Chow <brian@perfmode.com>
上级 f7cb6b99
...@@ -25,7 +25,7 @@ var ErrNotFound = errors.New("blockservice: key not found") ...@@ -25,7 +25,7 @@ var ErrNotFound = errors.New("blockservice: key not found")
type BlockService struct { type BlockService struct {
// TODO don't expose underlying impl details // TODO don't expose underlying impl details
Blockstore blockstore.Blockstore Blockstore blockstore.Blockstore
Remote exchange.Interface Exchange exchange.Interface
} }
// NewBlockService creates a BlockService with given datastore instance. // NewBlockService creates a BlockService with given datastore instance.
...@@ -36,7 +36,7 @@ func New(bs blockstore.Blockstore, rem exchange.Interface) (*BlockService, error ...@@ -36,7 +36,7 @@ func New(bs blockstore.Blockstore, rem exchange.Interface) (*BlockService, error
if rem == nil { if rem == nil {
log.Warning("blockservice running in local (offline) mode.") log.Warning("blockservice running in local (offline) mode.")
} }
return &BlockService{Blockstore: bs, Remote: rem}, nil return &BlockService{Blockstore: bs, Exchange: rem}, nil
} }
// AddBlock adds a particular block to the service, Putting it into the datastore. // 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,9 +66,9 @@ func (s *BlockService) AddBlock(b *blocks.Block) (u.Key, error) {
// TODO this operation rate-limits blockservice operations, we should // TODO this operation rate-limits blockservice operations, we should
// consider moving this to an sync process. // consider moving this to an sync process.
if s.Remote != nil { if s.Exchange != nil {
ctx := context.TODO() ctx := context.TODO()
err = s.Remote.HasBlock(ctx, b) err = s.Exchange.HasBlock(ctx, b)
} }
return k, err return k, err
} }
...@@ -82,9 +82,9 @@ func (s *BlockService) GetBlock(ctx context.Context, k u.Key) (*blocks.Block, er ...@@ -82,9 +82,9 @@ func (s *BlockService) GetBlock(ctx context.Context, k u.Key) (*blocks.Block, er
return block, nil return block, nil
// TODO be careful checking ErrNotFound. If the underlying // TODO be careful checking ErrNotFound. If the underlying
// implementation changes, this will break. // implementation changes, this will break.
} else if err == ds.ErrNotFound && s.Remote != nil { } else if err == ds.ErrNotFound && s.Exchange != nil {
log.Debug("Blockservice: Searching bitswap.") log.Debug("Blockservice: Searching bitswap.")
blk, err := s.Remote.GetBlock(ctx, k) blk, err := s.Exchange.GetBlock(ctx, k)
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -117,7 +117,7 @@ func (s *BlockService) GetBlocks(ctx context.Context, ks []u.Key) <-chan *blocks ...@@ -117,7 +117,7 @@ func (s *BlockService) GetBlocks(ctx context.Context, ks []u.Key) <-chan *blocks
} }
} }
rblocks, err := s.Remote.GetBlocks(ctx, misses) rblocks, err := s.Exchange.GetBlocks(ctx, misses)
if err != nil { if err != nil {
log.Errorf("Error with GetBlocks: %s", err) log.Errorf("Error with GetBlocks: %s", err)
return return
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论