Commit 110eef1d authored by Jeromy's avatar Jeromy

remove logging of dup blocks, move to counters for bitswap stat

parent d76b5e4a
...@@ -127,6 +127,9 @@ type Bitswap struct { ...@@ -127,6 +127,9 @@ type Bitswap struct {
newBlocks chan *blocks.Block newBlocks chan *blocks.Block
provideKeys chan u.Key provideKeys chan u.Key
blocksRecvd int
dupBlocksRecvd int
} }
type blockRequest struct { type blockRequest struct {
...@@ -219,14 +222,6 @@ func (bs *Bitswap) HasBlock(ctx context.Context, blk *blocks.Block) error { ...@@ -219,14 +222,6 @@ func (bs *Bitswap) HasBlock(ctx context.Context, blk *blocks.Block) error {
return errors.New("bitswap is closed") return errors.New("bitswap is closed")
default: 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 { if err := bs.blockstore.Put(blk); err != nil {
return err return err
...@@ -351,6 +346,10 @@ func (bs *Bitswap) ReceiveMessage(ctx context.Context, p peer.ID, incoming bsmsg ...@@ -351,6 +346,10 @@ func (bs *Bitswap) ReceiveMessage(ctx context.Context, p peer.ID, incoming bsmsg
// Should only track *useful* messages in ledger // Should only track *useful* messages in ledger
for _, block := range incoming.Blocks() { 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) hasBlockCtx, cancel := context.WithTimeout(ctx, hasBlockTimeout)
if err := bs.HasBlock(hasBlockCtx, block); err != nil { if err := bs.HasBlock(hasBlockCtx, block); err != nil {
log.Debug(err) log.Debug(err)
......
...@@ -6,15 +6,19 @@ import ( ...@@ -6,15 +6,19 @@ import (
) )
type Stat struct { type Stat struct {
ProvideBufLen int ProvideBufLen int
Wantlist []u.Key Wantlist []u.Key
Peers []string Peers []string
BlocksReceived int
DupBlksReceived int
} }
func (bs *Bitswap) Stat() (*Stat, error) { func (bs *Bitswap) Stat() (*Stat, error) {
st := new(Stat) st := new(Stat)
st.ProvideBufLen = len(bs.newBlocks) st.ProvideBufLen = len(bs.newBlocks)
st.Wantlist = bs.GetWantlist() st.Wantlist = bs.GetWantlist()
st.BlocksReceived = bs.blocksRecvd
st.DupBlksReceived = bs.dupBlocksRecvd
for _, p := range bs.engine.Peers() { for _, p := range bs.engine.Peers() {
st.Peers = append(st.Peers, p.Pretty()) st.Peers = append(st.Peers, p.Pretty())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment