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-bitswap
Commits
c0f399b9
Commit
c0f399b9
authored
Dec 02, 2014
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move public method to top of file
License: MIT Signed-off-by:
Brian Tiger Chow
<
brian@perfmode.com
>
parent
61599656
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
16 deletions
+16
-16
bitswap.go
bitswap.go
+16
-16
No files found.
bitswap.go
View file @
c0f399b9
...
...
@@ -145,6 +145,22 @@ func (bs *bitswap) GetBlocks(ctx context.Context, keys []u.Key) (<-chan *blocks.
}
}
// HasBlock announces the existance of a block to this bitswap service. The
// service will potentially notify its peers.
func
(
bs
*
bitswap
)
HasBlock
(
ctx
context
.
Context
,
blk
*
blocks
.
Block
)
error
{
if
err
:=
bs
.
blockstore
.
Put
(
blk
);
err
!=
nil
{
return
err
}
bs
.
wantlist
.
Remove
(
blk
.
Key
())
bs
.
notifications
.
Publish
(
blk
)
child
,
_
:=
context
.
WithTimeout
(
ctx
,
hasBlockTimeout
)
if
err
:=
bs
.
sendToPeersThatWant
(
child
,
blk
);
err
!=
nil
{
return
err
}
child
,
_
=
context
.
WithTimeout
(
ctx
,
hasBlockTimeout
)
return
bs
.
routing
.
Provide
(
child
,
blk
.
Key
())
}
func
(
bs
*
bitswap
)
sendWantListTo
(
ctx
context
.
Context
,
peers
<-
chan
peer
.
Peer
)
error
{
if
peers
==
nil
{
panic
(
"Cant send wantlist to nil peerchan"
)
...
...
@@ -245,22 +261,6 @@ func (bs *bitswap) loop(parent context.Context) {
}
}
// HasBlock announces the existance of a block to this bitswap service. The
// service will potentially notify its peers.
func
(
bs
*
bitswap
)
HasBlock
(
ctx
context
.
Context
,
blk
*
blocks
.
Block
)
error
{
if
err
:=
bs
.
blockstore
.
Put
(
blk
);
err
!=
nil
{
return
err
}
bs
.
wantlist
.
Remove
(
blk
.
Key
())
bs
.
notifications
.
Publish
(
blk
)
child
,
_
:=
context
.
WithTimeout
(
ctx
,
hasBlockTimeout
)
if
err
:=
bs
.
sendToPeersThatWant
(
child
,
blk
);
err
!=
nil
{
return
err
}
child
,
_
=
context
.
WithTimeout
(
ctx
,
hasBlockTimeout
)
return
bs
.
routing
.
Provide
(
child
,
blk
.
Key
())
}
// TODO(brian): handle errors
func
(
bs
*
bitswap
)
ReceiveMessage
(
ctx
context
.
Context
,
p
peer
.
Peer
,
incoming
bsmsg
.
BitSwapMessage
)
(
peer
.
Peer
,
bsmsg
.
BitSwapMessage
)
{
...
...
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