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
5d2b9d6c
Commit
5d2b9d6c
authored
Sep 28, 2016
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
only pass keys down newBlocks chan in bitswap
License: MIT Signed-off-by:
Jeromy
<
why@ipfs.io
>
parent
7dfc5ccf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
6 deletions
+11
-6
bitswap.go
bitswap.go
+8
-3
workers.go
workers.go
+3
-3
No files found.
bitswap.go
View file @
5d2b9d6c
...
...
@@ -90,7 +90,7 @@ func New(parent context.Context, p peer.ID, network bsnet.BitSwapNetwork,
network
:
network
,
findKeys
:
make
(
chan
*
blockRequest
,
sizeBatchRequestChan
),
process
:
px
,
newBlocks
:
make
(
chan
blocks
.
Block
,
HasBlockBufferSize
),
newBlocks
:
make
(
chan
key
.
Key
,
HasBlockBufferSize
),
provideKeys
:
make
(
chan
key
.
Key
,
provideKeysBufferSize
),
wm
:
NewWantManager
(
ctx
,
network
),
}
...
...
@@ -137,7 +137,7 @@ type Bitswap struct {
process
process
.
Process
newBlocks
chan
blocks
.
Block
newBlocks
chan
key
.
Key
provideKeys
chan
key
.
Key
...
...
@@ -308,12 +308,17 @@ func (bs *Bitswap) HasBlock(blk blocks.Block) error {
return
err
}
// NOTE: There exists the possiblity for a race condition here. If a user
// creates a node, then adds it to the dagservice while another goroutine
// is waiting on a GetBlock for that object, they will receive a reference
// to the same node. We should address this soon, but i'm not going to do
// it now as it requires more thought and isnt causing immediate problems.
bs
.
notifications
.
Publish
(
blk
)
bs
.
engine
.
AddBlock
(
blk
)
select
{
case
bs
.
newBlocks
<-
blk
:
case
bs
.
newBlocks
<-
blk
.
Key
()
:
// send block off to be reprovided
case
<-
bs
.
process
.
Closing
()
:
return
bs
.
process
.
Close
()
...
...
workers.go
View file @
5d2b9d6c
...
...
@@ -127,17 +127,17 @@ func (bs *Bitswap) provideCollector(ctx context.Context) {
for
{
select
{
case
blk
,
ok
:=
<-
bs
.
newBlocks
:
case
blk
ey
,
ok
:=
<-
bs
.
newBlocks
:
if
!
ok
{
log
.
Debug
(
"newBlocks channel closed"
)
return
}
if
keysOut
==
nil
{
nextKey
=
blk
.
Key
()
nextKey
=
blk
ey
keysOut
=
bs
.
provideKeys
}
else
{
toProvide
=
append
(
toProvide
,
blk
.
Key
()
)
toProvide
=
append
(
toProvide
,
blk
ey
)
}
case
keysOut
<-
nextKey
:
if
len
(
toProvide
)
>
0
{
...
...
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