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
26e6f28e
Commit
26e6f28e
authored
Nov 20, 2014
by
Brian Tiger Chow
Committed by
Jeromy
Dec 05, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(exchange) allow exchange to be closed
License: MIT Signed-off-by:
Brian Tiger Chow
<
brian@perfmode.com
>
parent
d6e2157a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
1 deletion
+12
-1
bitswap.go
bitswap.go
+12
-1
No files found.
bitswap.go
View file @
26e6f28e
...
...
@@ -25,9 +25,11 @@ var log = eventlog.Logger("bitswap")
// provided BitSwapNetwork. This function registers the returned instance as
// the network delegate.
// Runs until context is cancelled
func
New
(
ctx
context
.
Context
,
p
peer
.
Peer
,
network
bsnet
.
BitSwapNetwork
,
routing
bsnet
.
Routing
,
func
New
(
parent
context
.
Context
,
p
peer
.
Peer
,
network
bsnet
.
BitSwapNetwork
,
routing
bsnet
.
Routing
,
bstore
blockstore
.
Blockstore
,
nice
bool
)
exchange
.
Interface
{
ctx
,
cancelFunc
:=
context
.
WithCancel
(
parent
)
notif
:=
notifications
.
New
()
go
func
()
{
<-
ctx
.
Done
()
...
...
@@ -36,6 +38,7 @@ func New(ctx context.Context, p peer.Peer, network bsnet.BitSwapNetwork, routing
bs
:=
&
bitswap
{
blockstore
:
bstore
,
cancelFunc
:
cancelFunc
,
notifications
:
notif
,
strategy
:
strategy
.
New
(
nice
),
routing
:
routing
,
...
...
@@ -75,6 +78,9 @@ type bitswap struct {
strategy
strategy
.
Strategy
wantlist
u
.
KeySet
// cancelFunc signals cancellation to the bitswap event loop
cancelFunc
func
()
}
// GetBlock attempts to retrieve a particular block from peers within the
...
...
@@ -295,3 +301,8 @@ func (bs *bitswap) sendToPeersThatWant(ctx context.Context, block blocks.Block)
}
}
}
func
(
bs
*
bitswap
)
Close
()
error
{
bs
.
cancelFunc
()
return
nil
// to conform to Closer interface
}
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