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
3c559028
Commit
3c559028
authored
Jan 15, 2015
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rewrite as single line defer logs
parent
bae8b9f4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
16 deletions
+8
-16
exchange/bitswap/bitswap.go
exchange/bitswap/bitswap.go
+1
-2
p2p/crypto/secio/protocol.go
p2p/crypto/secio/protocol.go
+1
-2
routing/dht/dht.go
routing/dht/dht.go
+3
-6
routing/dht/routing.go
routing/dht/routing.go
+3
-6
No files found.
exchange/bitswap/bitswap.go
View file @
3c559028
...
...
@@ -120,12 +120,11 @@ func (bs *bitswap) GetBlock(parent context.Context, k u.Key) (*blocks.Block, err
ctx
,
cancelFunc
:=
context
.
WithCancel
(
parent
)
ctx
=
eventlog
.
ContextWithLoggable
(
ctx
,
eventlog
.
Uuid
(
"GetBlockRequest"
))
e
:=
log
.
EventBegin
(
ctx
,
"GetBlockRequest"
,
&
k
)
defer
log
.
EventBegin
(
ctx
,
"GetBlockRequest"
,
&
k
)
.
Done
()
log
.
Debugf
(
"GetBlockRequestBegin"
)
defer
func
()
{
cancelFunc
()
e
.
Done
()
log
.
Debugf
(
"GetBlockRequestEnd"
)
}()
...
...
p2p/crypto/secio/protocol.go
View file @
3c559028
...
...
@@ -81,8 +81,7 @@ func (s *secureSession) handshake(ctx context.Context, insecure io.ReadWriter) e
}
log
.
Debugf
(
"handshake: %s <--start--> %s"
,
s
.
localPeer
,
s
.
remotePeer
)
e
:=
log
.
EventBegin
(
ctx
,
"secureHandshake"
,
s
.
localPeer
)
defer
e
.
Done
()
defer
log
.
EventBegin
(
ctx
,
"secureHandshake"
,
s
.
localPeer
)
.
Done
()
s
.
local
.
permanentPubKey
=
s
.
localKey
.
GetPublic
()
myPubKeyBytes
,
err
:=
s
.
local
.
permanentPubKey
.
Bytes
()
...
...
routing/dht/dht.go
View file @
3c559028
...
...
@@ -196,8 +196,7 @@ func (dht *IpfsDHT) getValueOrPeers(ctx context.Context, p peer.ID,
// getValueSingle simply performs the get value RPC with the given parameters
func
(
dht
*
IpfsDHT
)
getValueSingle
(
ctx
context
.
Context
,
p
peer
.
ID
,
key
u
.
Key
)
(
*
pb
.
Message
,
error
)
{
e
:=
log
.
EventBegin
(
ctx
,
"getValueSingle"
,
p
,
&
key
)
defer
e
.
Done
()
defer
log
.
EventBegin
(
ctx
,
"getValueSingle"
,
p
,
&
key
)
.
Done
()
pmes
:=
pb
.
NewMessage
(
pb
.
Message_GET_VALUE
,
string
(
key
),
0
)
return
dht
.
sendRequest
(
ctx
,
p
,
pmes
)
...
...
@@ -267,16 +266,14 @@ func (dht *IpfsDHT) FindLocal(id peer.ID) peer.PeerInfo {
// findPeerSingle asks peer 'p' if they know where the peer with id 'id' is
func
(
dht
*
IpfsDHT
)
findPeerSingle
(
ctx
context
.
Context
,
p
peer
.
ID
,
id
peer
.
ID
)
(
*
pb
.
Message
,
error
)
{
e
:=
log
.
EventBegin
(
ctx
,
"findPeerSingle"
,
p
,
id
)
defer
e
.
Done
()
defer
log
.
EventBegin
(
ctx
,
"findPeerSingle"
,
p
,
id
)
.
Done
()
pmes
:=
pb
.
NewMessage
(
pb
.
Message_FIND_NODE
,
string
(
id
),
0
)
return
dht
.
sendRequest
(
ctx
,
p
,
pmes
)
}
func
(
dht
*
IpfsDHT
)
findProvidersSingle
(
ctx
context
.
Context
,
p
peer
.
ID
,
key
u
.
Key
)
(
*
pb
.
Message
,
error
)
{
e
:=
log
.
EventBegin
(
ctx
,
"findProvidersSingle"
,
p
,
&
key
)
defer
e
.
Done
()
defer
log
.
EventBegin
(
ctx
,
"findProvidersSingle"
,
p
,
&
key
)
.
Done
()
pmes
:=
pb
.
NewMessage
(
pb
.
Message_GET_PROVIDERS
,
string
(
key
),
0
)
return
dht
.
sendRequest
(
ctx
,
p
,
pmes
)
...
...
routing/dht/routing.go
View file @
3c559028
...
...
@@ -126,8 +126,7 @@ func (dht *IpfsDHT) Provide(ctx context.Context, key u.Key) error {
log
.
Debugf
(
"start"
,
key
)
defer
log
.
Debugf
(
"end"
,
key
)
e
:=
log
.
EventBegin
(
ctx
,
"provide"
,
&
key
)
defer
e
.
Done
()
defer
log
.
EventBegin
(
ctx
,
"provide"
,
&
key
)
.
Done
()
// add self locally
dht
.
providers
.
AddProvider
(
key
,
dht
.
self
)
...
...
@@ -246,8 +245,7 @@ func (dht *IpfsDHT) FindProvidersAsync(ctx context.Context, key u.Key, count int
func
(
dht
*
IpfsDHT
)
findProvidersAsyncRoutine
(
ctx
context
.
Context
,
key
u
.
Key
,
count
int
,
peerOut
chan
peer
.
PeerInfo
)
{
log
:=
dht
.
log
()
.
Prefix
(
"FindProviders(%s)"
,
key
)
e
:=
log
.
EventBegin
(
ctx
,
"findProvidersAsync"
,
&
key
)
defer
e
.
Done
()
defer
log
.
EventBegin
(
ctx
,
"findProvidersAsync"
,
&
key
)
.
Done
()
defer
close
(
peerOut
)
ps
:=
pset
.
NewLimited
(
count
)
...
...
@@ -317,8 +315,7 @@ func (dht *IpfsDHT) findProvidersAsyncRoutine(ctx context.Context, key u.Key, co
// FindPeer searches for a peer with given ID.
func
(
dht
*
IpfsDHT
)
FindPeer
(
ctx
context
.
Context
,
id
peer
.
ID
)
(
peer
.
PeerInfo
,
error
)
{
e
:=
log
.
EventBegin
(
ctx
,
"FindPeer"
,
id
)
defer
e
.
Done
()
defer
log
.
EventBegin
(
ctx
,
"FindPeer"
,
id
)
.
Done
()
// Check if were already connected to them
if
pi
:=
dht
.
FindLocal
(
id
);
pi
.
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