Commit ad14d6c5 authored by Brian Tiger Chow's avatar Brian Tiger Chow

refac(bitswap:interface) GetBlock, HaveBlock -> Block, HasBlock

parent d91955b4
......@@ -85,7 +85,7 @@ func NewSession(parent context.Context, p *peer.Peer, d ds.Datastore, r routing.
}
// GetBlock attempts to retrieve a particular block from peers, within timeout.
func (bs *BitSwap) GetBlock(k u.Key, timeout time.Duration) (
func (bs *BitSwap) Block(k u.Key, timeout time.Duration) (
*blocks.Block, error) {
u.DOut("Bitswap GetBlock: '%s'\n", k.Pretty())
begin := time.Now()
......@@ -139,9 +139,9 @@ func (bs *BitSwap) getBlock(k u.Key, p *peer.Peer, timeout time.Duration) (*bloc
return &block, nil
}
// HaveBlock announces the existance of a block to BitSwap, potentially sending
// HasBlock announces the existance of a block to BitSwap, potentially sending
// it to peers (Partners) whose WantLists include it.
func (bs *BitSwap) HaveBlock(blk *blocks.Block) error {
func (bs *BitSwap) HasBlock(blk *blocks.Block) error {
go func() {
for _, ledger := range bs.partners {
if ledger.WantListContains(blk.Key()) {
......
......@@ -11,13 +11,12 @@ type Exchange interface {
// Block returns the block associated with a given key.
// TODO(brian): pass a context instead of a timeout
// TODO(brian): rename -> Block
GetBlock(k u.Key, timeout time.Duration) (*blocks.Block, error)
Block(k u.Key, timeout time.Duration) (*blocks.Block, error)
// HasBlock asserts the existence of this block
// TODO(brian): rename -> HasBlock
// TODO(brian): accept a value, not a pointer
// TODO(brian): remove error return value. Should callers be concerned with
// whether the block was made available on the network?
HaveBlock(*blocks.Block) error
HasBlock(*blocks.Block) error
}
......@@ -42,7 +42,7 @@ func (s *BlockService) AddBlock(b *blocks.Block) (u.Key, error) {
return k, err
}
if s.Remote != nil {
err = s.Remote.HaveBlock(b)
err = s.Remote.HasBlock(b)
}
return k, err
}
......@@ -65,7 +65,7 @@ func (s *BlockService) GetBlock(k u.Key) (*blocks.Block, error) {
}, nil
} else if err == ds.ErrNotFound && s.Remote != nil {
u.DOut("Blockservice: Searching bitswap.\n")
blk, err := s.Remote.GetBlock(k, time.Second*5)
blk, err := s.Remote.Block(k, time.Second*5)
if err != nil {
return nil, err
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment