Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
ad14d6c5
Commit
ad14d6c5
authored
10 years ago
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refac(bitswap:interface) GetBlock, HaveBlock -> Block, HasBlock
parent
d91955b4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
8 deletions
+7
-8
bitswap/bitswap.go
bitswap/bitswap.go
+3
-3
bitswap/interface.go
bitswap/interface.go
+2
-3
blockservice/blockservice.go
blockservice/blockservice.go
+2
-2
No files found.
bitswap/bitswap.go
View file @
ad14d6c5
...
...
@@ -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
)
Get
Block
(
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
}
// Ha
ve
Block announces the existance of a block to BitSwap, potentially sending
// Ha
s
Block announces the existance of a block to BitSwap, potentially sending
// it to peers (Partners) whose WantLists include it.
func
(
bs
*
BitSwap
)
Ha
ve
Block
(
blk
*
blocks
.
Block
)
error
{
func
(
bs
*
BitSwap
)
Ha
s
Block
(
blk
*
blocks
.
Block
)
error
{
go
func
()
{
for
_
,
ledger
:=
range
bs
.
partners
{
if
ledger
.
WantListContains
(
blk
.
Key
())
{
...
...
This diff is collapsed.
Click to expand it.
bitswap/interface.go
View file @
ad14d6c5
...
...
@@ -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?
Ha
ve
Block
(
*
blocks
.
Block
)
error
Ha
s
Block
(
*
blocks
.
Block
)
error
}
This diff is collapsed.
Click to expand it.
blockservice/blockservice.go
View file @
ad14d6c5
...
...
@@ -42,7 +42,7 @@ func (s *BlockService) AddBlock(b *blocks.Block) (u.Key, error) {
return
k
,
err
}
if
s
.
Remote
!=
nil
{
err
=
s
.
Remote
.
Ha
ve
Block
(
b
)
err
=
s
.
Remote
.
Ha
s
Block
(
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
.
Get
Block
(
k
,
time
.
Second
*
5
)
blk
,
err
:=
s
.
Remote
.
Block
(
k
,
time
.
Second
*
5
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment