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-dms3
Commits
6f04302a
Commit
6f04302a
authored
9 years ago
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove logging of dup blocks, move to counters for bitswap stat
parent
f998339a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
11 deletions
+16
-11
core/commands/bitswap.go
core/commands/bitswap.go
+2
-0
exchange/bitswap/bitswap.go
exchange/bitswap/bitswap.go
+7
-8
exchange/bitswap/stat.go
exchange/bitswap/stat.go
+7
-3
No files found.
core/commands/bitswap.go
View file @
6f04302a
...
...
@@ -101,6 +101,8 @@ var bitswapStatCmd = &cmds.Command{
buf
:=
new
(
bytes
.
Buffer
)
fmt
.
Fprintln
(
buf
,
"bitswap status"
)
fmt
.
Fprintf
(
buf
,
"
\t
provides buffer: %d / %d
\n
"
,
out
.
ProvideBufLen
,
bitswap
.
HasBlockBufferSize
)
fmt
.
Fprintf
(
buf
,
"
\t
blocks received: %d
\n
"
,
out
.
BlocksReceived
)
fmt
.
Fprintf
(
buf
,
"
\t
dup blocks received: %d
\n
"
,
out
.
DupBlksReceived
)
fmt
.
Fprintf
(
buf
,
"
\t
wantlist [%d keys]
\n
"
,
len
(
out
.
Wantlist
))
for
_
,
k
:=
range
out
.
Wantlist
{
fmt
.
Fprintf
(
buf
,
"
\t\t
%s
\n
"
,
k
.
B58String
())
...
...
This diff is collapsed.
Click to expand it.
exchange/bitswap/bitswap.go
View file @
6f04302a
...
...
@@ -127,6 +127,9 @@ type Bitswap struct {
newBlocks
chan
*
blocks
.
Block
provideKeys
chan
u
.
Key
blocksRecvd
int
dupBlocksRecvd
int
}
type
blockRequest
struct
{
...
...
@@ -219,14 +222,6 @@ 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
...
...
@@ -351,6 +346,10 @@ func (bs *Bitswap) ReceiveMessage(ctx context.Context, p peer.ID, incoming bsmsg
// Should only track *useful* messages in ledger
for
_
,
block
:=
range
incoming
.
Blocks
()
{
bs
.
blocksRecvd
++
if
has
,
err
:=
bs
.
blockstore
.
Has
(
block
.
Key
());
err
==
nil
&&
has
{
bs
.
dupBlocksRecvd
++
}
hasBlockCtx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
hasBlockTimeout
)
if
err
:=
bs
.
HasBlock
(
hasBlockCtx
,
block
);
err
!=
nil
{
log
.
Debug
(
err
)
...
...
This diff is collapsed.
Click to expand it.
exchange/bitswap/stat.go
View file @
6f04302a
...
...
@@ -6,15 +6,19 @@ import (
)
type
Stat
struct
{
ProvideBufLen
int
Wantlist
[]
u
.
Key
Peers
[]
string
ProvideBufLen
int
Wantlist
[]
u
.
Key
Peers
[]
string
BlocksReceived
int
DupBlksReceived
int
}
func
(
bs
*
Bitswap
)
Stat
()
(
*
Stat
,
error
)
{
st
:=
new
(
Stat
)
st
.
ProvideBufLen
=
len
(
bs
.
newBlocks
)
st
.
Wantlist
=
bs
.
GetWantlist
()
st
.
BlocksReceived
=
bs
.
blocksRecvd
st
.
DupBlksReceived
=
bs
.
dupBlocksRecvd
for
_
,
p
:=
range
bs
.
engine
.
Peers
()
{
st
.
Peers
=
append
(
st
.
Peers
,
p
.
Pretty
())
...
...
This diff is collapsed.
Click to expand it.
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