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
f62acec4
Commit
f62acec4
authored
Sep 15, 2015
by
Juan Benet
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1701 from ipfs/feat/extract-logging
extract logging
parents
2d917bab
d7ed6e95
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
13 deletions
+13
-13
bitswap.go
bitswap.go
+3
-3
decision/engine.go
decision/engine.go
+2
-2
network/ipfs_impl.go
network/ipfs_impl.go
+2
-2
workers.go
workers.go
+6
-6
No files found.
bitswap.go
View file @
f62acec4
...
...
@@ -22,10 +22,10 @@ import (
wantlist
"github.com/ipfs/go-ipfs/exchange/bitswap/wantlist"
peer
"github.com/ipfs/go-ipfs/p2p/peer"
"github.com/ipfs/go-ipfs/thirdparty/delay"
eventlo
g
"github.com/ipfs/go-ipfs/
thirdparty/eventlog
"
loggin
g
"github.com/ipfs/go-ipfs/
vendor/go-log-v1.0.0
"
)
var
log
=
eventlo
g
.
Logger
(
"bitswap"
)
var
log
=
loggin
g
.
Logger
(
"bitswap"
)
const
(
// maxProvidersPerRequest specifies the maximum number of providers desired
...
...
@@ -151,7 +151,7 @@ func (bs *Bitswap) GetBlock(parent context.Context, k key.Key) (*blocks.Block, e
ctx
,
cancelFunc
:=
context
.
WithCancel
(
parent
)
ctx
=
eventlo
g
.
ContextWithLoggable
(
ctx
,
eventlo
g
.
Uuid
(
"GetBlockRequest"
))
ctx
=
loggin
g
.
ContextWithLoggable
(
ctx
,
loggin
g
.
Uuid
(
"GetBlockRequest"
))
log
.
Event
(
ctx
,
"Bitswap.GetBlockRequest.Start"
,
&
k
)
defer
log
.
Event
(
ctx
,
"Bitswap.GetBlockRequest.End"
,
&
k
)
...
...
decision/engine.go
View file @
f62acec4
...
...
@@ -10,7 +10,7 @@ import (
bsmsg
"github.com/ipfs/go-ipfs/exchange/bitswap/message"
wl
"github.com/ipfs/go-ipfs/exchange/bitswap/wantlist"
peer
"github.com/ipfs/go-ipfs/p2p/peer"
eventlo
g
"github.com/ipfs/go-ipfs/
thirdparty/eventlog
"
loggin
g
"github.com/ipfs/go-ipfs/
vendor/go-log-v1.0.0
"
)
// TODO consider taking responsibility for other types of requests. For
...
...
@@ -43,7 +43,7 @@ import (
// whatever it sees fit to produce desired outcomes (get wanted keys
// quickly, maintain good relationships with peers, etc).
var
log
=
eventlo
g
.
Logger
(
"engine"
)
var
log
=
loggin
g
.
Logger
(
"engine"
)
const
(
// outboxChanBuffer must be 0 to prevent stale messages from being sent
...
...
network/ipfs_impl.go
View file @
f62acec4
...
...
@@ -9,10 +9,10 @@ import (
inet
"github.com/ipfs/go-ipfs/p2p/net"
peer
"github.com/ipfs/go-ipfs/p2p/peer"
routing
"github.com/ipfs/go-ipfs/routing"
eventlo
g
"github.com/ipfs/go-ipfs/
thirdparty/eventlog
"
loggin
g
"github.com/ipfs/go-ipfs/
vendor/go-log-v1.0.0
"
)
var
log
=
eventlo
g
.
Logger
(
"bitswap_network"
)
var
log
=
loggin
g
.
Logger
(
"bitswap_network"
)
// NewFromIpfsHost returns a BitSwapNetwork supported by underlying IPFS host
func
NewFromIpfsHost
(
host
host
.
Host
,
r
routing
.
IpfsRouting
)
BitSwapNetwork
{
...
...
workers.go
View file @
f62acec4
...
...
@@ -9,7 +9,7 @@ import (
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
key
"github.com/ipfs/go-ipfs/blocks/key"
eventlo
g
"github.com/ipfs/go-ipfs/
thirdparty/eventlog
"
loggin
g
"github.com/ipfs/go-ipfs/
vendor/go-log-v1.0.0
"
)
var
TaskWorkerCount
=
8
...
...
@@ -45,7 +45,7 @@ func (bs *Bitswap) startWorkers(px process.Process, ctx context.Context) {
}
func
(
bs
*
Bitswap
)
taskWorker
(
ctx
context
.
Context
,
id
int
)
{
idmap
:=
eventlo
g
.
LoggableMap
{
"ID"
:
id
}
idmap
:=
loggin
g
.
LoggableMap
{
"ID"
:
id
}
defer
log
.
Info
(
"bitswap task worker shutting down..."
)
for
{
log
.
Event
(
ctx
,
"Bitswap.TaskWorker.Loop"
,
idmap
)
...
...
@@ -56,7 +56,7 @@ func (bs *Bitswap) taskWorker(ctx context.Context, id int) {
if
!
ok
{
continue
}
log
.
Event
(
ctx
,
"Bitswap.TaskWorker.Work"
,
eventlo
g
.
LoggableMap
{
log
.
Event
(
ctx
,
"Bitswap.TaskWorker.Work"
,
loggin
g
.
LoggableMap
{
"ID"
:
id
,
"Target"
:
envelope
.
Peer
.
Pretty
(),
"Block"
:
envelope
.
Block
.
Multihash
.
B58String
(),
...
...
@@ -77,7 +77,7 @@ func (bs *Bitswap) provideWorker(px process.Process) {
limiter
:=
ratelimit
.
NewRateLimiter
(
px
,
provideWorkerMax
)
limitedGoProvide
:=
func
(
k
key
.
Key
,
wid
int
)
{
ev
:=
eventlo
g
.
LoggableMap
{
"ID"
:
wid
}
ev
:=
loggin
g
.
LoggableMap
{
"ID"
:
wid
}
limiter
.
LimitedGo
(
func
(
px
process
.
Process
)
{
ctx
:=
procctx
.
OnClosingContext
(
px
)
// derive ctx from px
...
...
@@ -96,7 +96,7 @@ func (bs *Bitswap) provideWorker(px process.Process) {
// _ratelimited_ number of workers to handle each key.
limiter
.
Go
(
func
(
px
process
.
Process
)
{
for
wid
:=
2
;
;
wid
++
{
ev
:=
eventlo
g
.
LoggableMap
{
"ID"
:
1
}
ev
:=
loggin
g
.
LoggableMap
{
"ID"
:
1
}
log
.
Event
(
procctx
.
OnClosingContext
(
px
),
"Bitswap.ProvideWorker.Loop"
,
ev
)
select
{
...
...
@@ -158,7 +158,7 @@ func (bs *Bitswap) providerConnector(parent context.Context) {
log
.
Warning
(
"Received batch request for zero blocks"
)
continue
}
log
.
Event
(
parent
,
"Bitswap.ProviderConnector.Work"
,
eventlo
g
.
LoggableMap
{
"Keys"
:
keys
})
log
.
Event
(
parent
,
"Bitswap.ProviderConnector.Work"
,
loggin
g
.
LoggableMap
{
"Keys"
:
keys
})
// NB: Optimization. Assumes that providers of key[0] are likely to
// be able to provide for all keys. This currently holds true in most
...
...
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