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
806b3c29
Commit
806b3c29
authored
10 years ago
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refac(bs:msg) msg.Wantlist() returns []u.Key
parent
96ab8343
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
8 deletions
+11
-8
bitswap/bitswap.go
bitswap/bitswap.go
+4
-5
bitswap/message/message.go
bitswap/message/message.go
+7
-3
No files found.
bitswap/bitswap.go
View file @
806b3c29
...
...
@@ -192,15 +192,14 @@ func (bs *BitSwap) handleMessages() {
// peerWantsBlock will check if we have the block in question,
// and then if we do, check the ledger for whether or not we should send it.
func
(
bs
*
BitSwap
)
peerWantsBlock
(
p
*
peer
.
Peer
,
want
string
)
{
u
.
DOut
(
"peer [%s] wants block [%s]
\n
"
,
p
.
ID
.
Pretty
(),
u
.
Key
(
want
)
.
Pretty
())
func
(
bs
*
BitSwap
)
peerWantsBlock
(
p
*
peer
.
Peer
,
want
ed
u
.
Key
)
{
u
.
DOut
(
"peer [%s] wants block [%s]
\n
"
,
p
.
ID
.
Pretty
(),
want
ed
.
Pretty
())
ledger
:=
bs
.
getLedger
(
p
)
dsk
:=
ds
.
NewKey
(
want
)
blk_i
,
err
:=
bs
.
datastore
.
Get
(
dsk
)
blk_i
,
err
:=
bs
.
datastore
.
Get
(
wanted
.
DatastoreKey
())
if
err
!=
nil
{
if
err
==
ds
.
ErrNotFound
{
ledger
.
Wants
(
u
.
Key
(
want
)
)
ledger
.
Wants
(
want
ed
)
}
u
.
PErr
(
"datastore get error: %v
\n
"
,
err
)
return
...
...
This diff is collapsed.
Click to expand it.
bitswap/message/message.go
View file @
806b3c29
...
...
@@ -14,7 +14,7 @@ import (
)
type
BitSwapMessage
interface
{
Wantlist
()
[]
string
Wantlist
()
[]
u
.
Key
Blocks
()
[]
blocks
.
Block
AppendWanted
(
k
u
.
Key
)
AppendBlock
(
b
*
blocks
.
Block
)
...
...
@@ -41,8 +41,12 @@ func New() *message {
}
// TODO(brian): convert these into keys
func
(
m
*
message
)
Wantlist
()
[]
string
{
return
m
.
pb
.
Wantlist
func
(
m
*
message
)
Wantlist
()
[]
u
.
Key
{
wl
:=
make
([]
u
.
Key
,
len
(
m
.
pb
.
Wantlist
))
for
_
,
str
:=
range
m
.
pb
.
Wantlist
{
wl
=
append
(
wl
,
u
.
Key
(
str
))
}
return
wl
}
// TODO(brian): convert these into blocks
...
...
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