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
a1530f84
Commit
a1530f84
authored
May 31, 2017
by
zramsay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apply the megacheck tool to improve code quality
License: MIT Signed-off-by:
Zach Ramsay
<
zach.ramsay@gmail.com
>
parent
940ef108
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
10 additions
and
26 deletions
+10
-26
bitswap.go
bitswap.go
+3
-3
bitswap_test.go
bitswap_test.go
+1
-11
message/message.go
message/message.go
+2
-8
testutils.go
testutils.go
+2
-2
wantmanager.go
wantmanager.go
+2
-2
No files found.
bitswap.go
View file @
a1530f84
...
@@ -37,9 +37,9 @@ const (
...
@@ -37,9 +37,9 @@ const (
// TODO: if a 'non-nice' strategy is implemented, consider increasing this value
// TODO: if a 'non-nice' strategy is implemented, consider increasing this value
maxProvidersPerRequest
=
3
maxProvidersPerRequest
=
3
providerRequestTimeout
=
time
.
Second
*
10
providerRequestTimeout
=
time
.
Second
*
10
hasBlockTimeout
=
time
.
Second
*
15
//
hasBlockTimeout = time.Second * 15
provideTimeout
=
time
.
Second
*
15
provideTimeout
=
time
.
Second
*
15
sizeBatchRequestChan
=
32
sizeBatchRequestChan
=
32
// kMaxPriority is the max priority as defined by the bitswap protocol
// kMaxPriority is the max priority as defined by the bitswap protocol
kMaxPriority
=
math
.
MaxInt32
kMaxPriority
=
math
.
MaxInt32
)
)
...
...
bitswap_test.go
View file @
a1530f84
...
@@ -199,7 +199,7 @@ func PerformDistributionTest(t *testing.T, numInstances, numBlocks int) {
...
@@ -199,7 +199,7 @@ func PerformDistributionTest(t *testing.T, numInstances, numBlocks int) {
if
err
!=
nil
{
if
err
!=
nil
{
errs
<-
err
errs
<-
err
}
}
for
_
=
range
outch
{
for
range
outch
{
}
}
}(
inst
)
}(
inst
)
}
}
...
@@ -226,16 +226,6 @@ func PerformDistributionTest(t *testing.T, numInstances, numBlocks int) {
...
@@ -226,16 +226,6 @@ func PerformDistributionTest(t *testing.T, numInstances, numBlocks int) {
}
}
}
}
func
getOrFail
(
bitswap
Instance
,
b
blocks
.
Block
,
t
*
testing
.
T
,
wg
*
sync
.
WaitGroup
)
{
if
_
,
err
:=
bitswap
.
Blockstore
()
.
Get
(
b
.
Cid
());
err
!=
nil
{
_
,
err
:=
bitswap
.
Exchange
.
GetBlock
(
context
.
Background
(),
b
.
Cid
())
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
wg
.
Done
()
}
// TODO simplify this test. get to the _essence_!
// TODO simplify this test. get to the _essence_!
func
TestSendToWantingPeer
(
t
*
testing
.
T
)
{
func
TestSendToWantingPeer
(
t
*
testing
.
T
)
{
if
testing
.
Short
()
{
if
testing
.
Short
()
{
...
...
message/message.go
View file @
a1530f84
...
@@ -220,19 +220,13 @@ func (m *impl) ToProtoV1() *pb.Message {
...
@@ -220,19 +220,13 @@ func (m *impl) ToProtoV1() *pb.Message {
func
(
m
*
impl
)
ToNetV0
(
w
io
.
Writer
)
error
{
func
(
m
*
impl
)
ToNetV0
(
w
io
.
Writer
)
error
{
pbw
:=
ggio
.
NewDelimitedWriter
(
w
)
pbw
:=
ggio
.
NewDelimitedWriter
(
w
)
if
err
:=
pbw
.
WriteMsg
(
m
.
ToProtoV0
());
err
!=
nil
{
return
pbw
.
WriteMsg
(
m
.
ToProtoV0
())
return
err
}
return
nil
}
}
func
(
m
*
impl
)
ToNetV1
(
w
io
.
Writer
)
error
{
func
(
m
*
impl
)
ToNetV1
(
w
io
.
Writer
)
error
{
pbw
:=
ggio
.
NewDelimitedWriter
(
w
)
pbw
:=
ggio
.
NewDelimitedWriter
(
w
)
if
err
:=
pbw
.
WriteMsg
(
m
.
ToProtoV1
());
err
!=
nil
{
return
pbw
.
WriteMsg
(
m
.
ToProtoV1
())
return
err
}
return
nil
}
}
func
(
m
*
impl
)
Loggable
()
map
[
string
]
interface
{}
{
func
(
m
*
impl
)
Loggable
()
map
[
string
]
interface
{}
{
...
...
testutils.go
View file @
a1530f84
...
@@ -88,8 +88,8 @@ func (i *Instance) SetBlockstoreLatency(t time.Duration) time.Duration {
...
@@ -88,8 +88,8 @@ func (i *Instance) SetBlockstoreLatency(t time.Duration) time.Duration {
// just a much better idea.
// just a much better idea.
func
Session
(
ctx
context
.
Context
,
net
tn
.
Network
,
p
testutil
.
Identity
)
Instance
{
func
Session
(
ctx
context
.
Context
,
net
tn
.
Network
,
p
testutil
.
Identity
)
Instance
{
bsdelay
:=
delay
.
Fixed
(
0
)
bsdelay
:=
delay
.
Fixed
(
0
)
const
bloomSize
=
512
//
const bloomSize = 512
const
writeCacheElems
=
100
//
const writeCacheElems = 100
adapter
:=
net
.
Adapter
(
p
)
adapter
:=
net
.
Adapter
(
p
)
dstore
:=
ds_sync
.
MutexWrap
(
datastore2
.
WithDelay
(
ds
.
NewMapDatastore
(),
bsdelay
))
dstore
:=
ds_sync
.
MutexWrap
(
datastore2
.
WithDelay
(
ds
.
NewMapDatastore
(),
bsdelay
))
...
...
wantmanager.go
View file @
a1530f84
...
@@ -55,7 +55,7 @@ func NewWantManager(ctx context.Context, network bsnet.BitSwapNetwork) *WantMana
...
@@ -55,7 +55,7 @@ func NewWantManager(ctx context.Context, network bsnet.BitSwapNetwork) *WantMana
}
}
}
}
type
msgPair
struct
{
/*
type msgPair struct {
to peer.ID
to peer.ID
msg bsmsg.BitSwapMessage
msg bsmsg.BitSwapMessage
}
}
...
@@ -63,7 +63,7 @@ type msgPair struct {
...
@@ -63,7 +63,7 @@ type msgPair struct {
type cancellation struct {
type cancellation struct {
who peer.ID
who peer.ID
blk *cid.Cid
blk *cid.Cid
}
}
*/
type
msgQueue
struct
{
type
msgQueue
struct
{
p
peer
.
ID
p
peer
.
ID
...
...
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