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
110eef1d
Commit
110eef1d
authored
May 04, 2015
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove logging of dup blocks, move to counters for bitswap stat
parent
d76b5e4a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
11 deletions
+14
-11
bitswap.go
bitswap.go
+7
-8
stat.go
stat.go
+7
-3
No files found.
bitswap.go
View file @
110eef1d
...
...
@@ -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
)
...
...
stat.go
View file @
110eef1d
...
...
@@ -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
())
...
...
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