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
d76b5e4a
Commit
d76b5e4a
authored
Apr 29, 2015
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove some redundant blockputs to avoid false duplicate block receives
parent
36427bde
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
5 deletions
+10
-5
bitswap.go
bitswap.go
+9
-0
bitswap_test.go
bitswap_test.go
+1
-5
No files found.
bitswap.go
View file @
d76b5e4a
...
...
@@ -219,6 +219,15 @@ func (bs *Bitswap) HasBlock(ctx context.Context, blk *blocks.Block) error {
return
errors
.
New
(
"bitswap is closed"
)
default
:
}
has
,
err
:=
bs
.
blockstore
.
Has
(
blk
.
Key
())
if
err
!=
nil
{
return
err
}
if
has
{
log
.
Error
(
bs
.
self
,
"Dup Block! "
,
blk
.
Key
())
}
if
err
:=
bs
.
blockstore
.
Put
(
blk
);
err
!=
nil
{
return
err
}
...
...
bitswap_test.go
View file @
d76b5e4a
...
...
@@ -69,9 +69,6 @@ func TestGetBlockFromPeerAfterPeerAnnounces(t *testing.T) {
hasBlock
:=
g
.
Next
()
defer
hasBlock
.
Exchange
.
Close
()
if
err
:=
hasBlock
.
Blockstore
()
.
Put
(
block
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
err
:=
hasBlock
.
Exchange
.
HasBlock
(
context
.
Background
(),
block
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -136,7 +133,6 @@ func PerformDistributionTest(t *testing.T, numInstances, numBlocks int) {
var
blkeys
[]
u
.
Key
first
:=
instances
[
0
]
for
_
,
b
:=
range
blocks
{
first
.
Blockstore
()
.
Put
(
b
)
// TODO remove. don't need to do this. bitswap owns block
blkeys
=
append
(
blkeys
,
b
.
Key
())
first
.
Exchange
.
HasBlock
(
context
.
Background
(),
b
)
}
...
...
@@ -144,7 +140,7 @@ func PerformDistributionTest(t *testing.T, numInstances, numBlocks int) {
t
.
Log
(
"Distribute!"
)
wg
:=
sync
.
WaitGroup
{}
for
_
,
inst
:=
range
instances
{
for
_
,
inst
:=
range
instances
[
1
:
]
{
wg
.
Add
(
1
)
go
func
(
inst
Instance
)
{
defer
wg
.
Done
()
...
...
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